added post voting
This commit is contained in:
@@ -38,7 +38,7 @@ class CommentTest < ActiveSupport::TestCase
|
||||
post = Factory.create(:post)
|
||||
c1 = Factory.create(:comment, :post => post)
|
||||
assert_nothing_raised {c1.vote!(user, true)}
|
||||
assert_raise(Comment::VotingError) {c1.vote!(user, true)}
|
||||
assert_raise(CommentVote::Error) {c1.vote!(user, true)}
|
||||
assert_equal(1, CommentVote.count)
|
||||
|
||||
c2 = Factory.create(:comment, :post => post)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CommentVoteTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -405,4 +405,16 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_equal(post3.id, relation.first.id)
|
||||
end
|
||||
end
|
||||
|
||||
context "Voting on a post" do
|
||||
should "not allow duplicate votes" do
|
||||
user = Factory.create(:user)
|
||||
post = Factory.create(:post)
|
||||
assert_nothing_raised {post.vote!(user, true)}
|
||||
assert_raise(PostVote::Error) {post.vote!(user, true)}
|
||||
post.reload
|
||||
assert_equal(1, PostVote.count)
|
||||
assert_equal(1, post.score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user