Show other comments on post when editing a comment.

This commit is contained in:
Miles Gould committed 2013-04-29 21:44:30 +01:00
1 parent 2b84fa8bad
commit c53dd6797f
4 files changed
+11 -4

No files matched your search

+1
View File
@@ -43,6 +43,7 @@ class CommentsController < ApplicationController
# GET /comments/1/edit
def edit
@comment = Comment.find(params[:id])
@comments = @comment.post.comments
end
# POST /comments
+1 -1
View File
@@ -1,5 +1,5 @@
%a{:name => "comments"}
- if !@comments.empty?
- if @comments
%h2
=pluralize(@comments.length, "comment")
- @comments.each do |c|
@@ -57,6 +57,15 @@ describe CommentsController do
get :edit, {:id => comment.to_param}
assigns(:comment).should eq(comment)
end
it "assigns previous comments as @comments" do
post = FactoryGirl.create(:post)
old_comment = FactoryGirl.create(:comment, :post => post)
comment = FactoryGirl.create(:comment, :post => post)
get :edit, {:id => comment.to_param}
assigns(:comments).should eq([old_comment, comment])
end
end
describe "POST create" do
-3
View File
@@ -107,7 +107,4 @@ describe "posts/show" do
end
end