mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-24 09:43:24 -04:00
add count of comments to posts partial
This commit is contained in:
committed by
Miles Gould
parent
1bc963d169
commit
cf678a45c4
@@ -21,3 +21,6 @@
|
||||
:markdown
|
||||
#{ strip_tags post.body }
|
||||
|
||||
.post-comments
|
||||
= pluralize post.comments.count, "comment"
|
||||
|
||||
|
||||
51
spec/views/posts/_single.html.haml_spec.rb
Normal file
51
spec/views/posts/_single.html.haml_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "posts/_single" do
|
||||
before(:each) do
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
context "0 comments" do
|
||||
before(:each) do
|
||||
render :partial => "single", :locals => {
|
||||
:post => @post
|
||||
}
|
||||
end
|
||||
|
||||
it "renders the number of comments" do
|
||||
rendered.should contain "0 comments"
|
||||
end
|
||||
end
|
||||
|
||||
context "1 comment" do
|
||||
before(:each) do
|
||||
@comment = FactoryGirl.create(:comment, :post => @post)
|
||||
render :partial => "single", :locals => {
|
||||
:post => @post
|
||||
}
|
||||
end
|
||||
|
||||
it "renders the number of comments" do
|
||||
rendered.should contain "1 comment"
|
||||
end
|
||||
end
|
||||
|
||||
context "2 comments" do
|
||||
before(:each) do
|
||||
@comment = FactoryGirl.create(:comment, :post => @post)
|
||||
@comment2 = FactoryGirl.create(:comment, :post => @post)
|
||||
render :partial => "single", :locals => {
|
||||
:post => @post
|
||||
}
|
||||
end
|
||||
|
||||
it "renders the number of comments" do
|
||||
rendered.should contain "2 comments"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user