diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index b133a1cdc..b62f2fb5e 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -159,16 +159,15 @@ class CommentTest < ActiveSupport::TestCase user = FactoryGirl.create(:user) post = FactoryGirl.create(:post) c1 = FactoryGirl.create(:comment, :post => post) - comment_vote = c1.vote!("down") - assert_equal([], comment_vote.errors.full_messages) - comment_vote = c1.vote!("down") - assert_equal(["You have already voted for this comment"], comment_vote.errors.full_messages) + + assert_nothing_raised { c1.vote!("down") } + exception = assert_raises(ActiveRecord::RecordInvalid) { c1.vote!("down") } + assert_equal("Validation failed: You have already voted for this comment", exception.message) assert_equal(1, CommentVote.count) assert_equal(-1, CommentVote.last.score) c2 = FactoryGirl.create(:comment, :post => post) - comment_vote = c2.vote!("down") - assert_equal([], comment_vote.errors.full_messages) + assert_nothing_raised { c2.vote!("down") } assert_equal(2, CommentVote.count) end @@ -176,9 +175,9 @@ class CommentTest < ActiveSupport::TestCase user = FactoryGirl.create(:user) post = FactoryGirl.create(:post) c1 = FactoryGirl.create(:comment, :post => post) - comment_vote = c1.vote!("up") - assert_equal(["You cannot upvote your own comments"], comment_vote.errors.full_messages) + exception = assert_raises(ActiveRecord::RecordInvalid) { c1.vote!("up") } + assert_equal("Validation failed: You cannot upvote your own comments", exception.message) end should "allow undoing of votes" do