Add tests for stickying comments.

This commit is contained in:
evazion
2016-12-26 23:37:16 -06:00
parent 82e93b3c12
commit 0e73f3c8a9
2 changed files with 96 additions and 5 deletions

View File

@@ -205,6 +205,26 @@ class CommentTest < ActiveSupport::TestCase
assert_equal(c2.id, matches.all[0].id)
assert_equal(c1.id, matches.all[1].id)
end
context "that is below the score threshold" do
should "be hidden if not stickied" do
user = FactoryGirl.create(:user, :comment_threshold => 0)
post = FactoryGirl.create(:post)
comment = FactoryGirl.create(:comment, :post => post, :score => -5)
assert_equal([comment], post.comments.hidden(user))
assert_equal([], post.comments.visible(user))
end
should "be visible if stickied" do
user = FactoryGirl.create(:user, :comment_threshold => 0)
post = FactoryGirl.create(:post)
comment = FactoryGirl.create(:comment, :post => post, :score => -5, :is_sticky => true)
assert_equal([], post.comments.hidden(user))
assert_equal([comment], post.comments.visible(user))
end
end
end
end
end