mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-16 12:40:07 -04:00
limit to recent comments
This commit is contained in:
@@ -3,6 +3,7 @@ class CommentsController < ApplicationController
|
||||
# GET /comments.json
|
||||
def index
|
||||
@comments = Comment.all
|
||||
@recent_comments = Comment.limit(100).order('created_at desc').all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
= content_for :title, "Recent comments"
|
||||
|
||||
- @comments.reverse.each do |comment|
|
||||
- @recent_comments.each do |comment|
|
||||
%h2
|
||||
Comment on
|
||||
= link_to comment.post.subject, comment.post
|
||||
|
||||
@@ -14,6 +14,7 @@ describe CommentsController do
|
||||
comment = Comment.create! valid_attributes
|
||||
get :index, {}
|
||||
assigns(:comments).should eq([comment])
|
||||
assigns(:recent_comments).should eq([comment])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe "comments/index" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
assign(:comments, [
|
||||
assign(:recent_comments, [
|
||||
FactoryGirl.create(:comment),
|
||||
FactoryGirl.create(:comment, :body => 'ROFL')
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user