diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml
index d08c586ef..abc2fcc5f 100644
--- a/app/views/posts/_single.html.haml
+++ b/app/views/posts/_single.html.haml
@@ -24,7 +24,8 @@
- unless defined?(hide_comments)
.post-comments
%ul.inline
- %li.first= link_to pluralize(post.comments.count, "comment"), post
+ %li.first= link_to pluralize(post.comments.count, "comment"),
+ post_path(post, :anchor => 'comments')
-if can? :create, Comment
%li= link_to "Reply", new_comment_path(:post_id => post.id)
%li= link_to "Permalink", post
diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb
index 12e3dd58e..eebac11f4 100644
--- a/spec/views/posts/_single.html.haml_spec.rb
+++ b/spec/views/posts/_single.html.haml_spec.rb
@@ -62,7 +62,7 @@ describe "posts/_single" do
end
it "renders the number of comments" do
- rendered.should contain "0 comments"
+ assert_select "a[href=#{post_path(@post)}\#comments]", "0 comments"
end
end
@@ -73,11 +73,7 @@ describe "posts/_single" do
end
it "renders the number of comments" do
- rendered.should contain "1 comment"
- end
-
- it "contains a link to post" do
- assert_select "a[href=#{post_path @post}]"
+ assert_select "a[href=#{post_path(@post)}\#comments]", "1 comment"
end
end
@@ -89,7 +85,7 @@ describe "posts/_single" do
end
it "renders the number of comments" do
- rendered.should contain "2 comments"
+ assert_select "a[href=#{post_path(@post)}\#comments]", "2 comments"
end
end
diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb
index fd73a3a9f..684009801 100644
--- a/spec/views/posts/index.html.haml_spec.rb
+++ b/spec/views/posts/index.html.haml_spec.rb
@@ -6,6 +6,8 @@ describe "posts/index" do
@author = FactoryGirl.create(:member)
@post1 = FactoryGirl.build(:post, :author => @author)
@post2 = FactoryGirl.build(:post, :author => @author)
+ @post1.save # needed to generate slugs and hence paths for posts
+ @post2.save
assign(:posts, [@post1, @post2])
render
end