mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-03 22:54:21 -04:00
Show other comments on post when editing a comment.
This commit is contained in:
@@ -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,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
|
||||
|
||||
@@ -107,7 +107,4 @@ describe "posts/show" do
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user