added post voting

This commit is contained in:
albert
2010-02-15 17:45:09 -05:00
parent 80f033f253
commit 9f353c32f4
10 changed files with 112 additions and 19 deletions

View File

@@ -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