add tests for #1263
This commit is contained in:
@@ -102,6 +102,19 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
assert_equal(2, CommentVote.count)
|
assert_equal(2, CommentVote.count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "allow undoing of votes" do
|
||||||
|
user = FactoryGirl.create(:user)
|
||||||
|
post = FactoryGirl.create(:post)
|
||||||
|
comment = FactoryGirl.create(:comment, :post => post)
|
||||||
|
CurrentUser.scoped(user, "127.0.0.1") do
|
||||||
|
comment.vote!("up")
|
||||||
|
comment.unvote!
|
||||||
|
comment.reload
|
||||||
|
assert_equal(0, comment.score)
|
||||||
|
assert_nothing_raised {comment.vote!("down")}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
should "be searchable" do
|
should "be searchable" do
|
||||||
c1 = FactoryGirl.create(:comment, :body => "aaa bbb ccc")
|
c1 = FactoryGirl.create(:comment, :body => "aaa bbb ccc")
|
||||||
c2 = FactoryGirl.create(:comment, :body => "aaa ddd")
|
c2 = FactoryGirl.create(:comment, :body => "aaa ddd")
|
||||||
|
|||||||
@@ -1138,6 +1138,18 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_equal(1, post.score)
|
assert_equal(1, post.score)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "allow undoing of votes" do
|
||||||
|
user = FactoryGirl.create(:user)
|
||||||
|
post = FactoryGirl.create(:post)
|
||||||
|
CurrentUser.scoped(user, "127.0.0.1") do
|
||||||
|
post.vote!("up")
|
||||||
|
post.unvote!
|
||||||
|
post.reload
|
||||||
|
assert_equal(0, post.score)
|
||||||
|
assert_nothing_raised {post.vote!("down")}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Counting:" do
|
context "Counting:" do
|
||||||
|
|||||||
Reference in New Issue
Block a user