fixed comment vote functional test

This commit is contained in:
albert
2011-04-01 19:01:17 -04:00
parent e7748e1fc9
commit cbd877d020
43 changed files with 135 additions and 20369 deletions

View File

@@ -37,23 +37,14 @@ class Comment < ActiveRecord::Base
end
def vote!(score)
if !CurrentUser.user.can_comment_vote?
raise CommentVote::Error.new("You can only vote ten times an hour on comments")
elsif score == "down" && creator.is_janitor?
raise CommentVote::Error.new("You cannot downvote janitor/moderator/admin comments")
elsif votes.find_by_user_id(CurrentUser.user.id).nil?
if score == "up"
increment!(:score)
elsif score == "down"
decrement!(:score)
end
votes.create
else
raise CommentVote::Error.new("You have already voted for this comment")
vote = votes.create(:score => score)
if vote.errors.any?
raise CommentVote::Error.new(vote.errors.full_messages.join("; "))
elsif vote.is_positive?
increment!(:score)
elsif vote.is_negative?
decrement!(:score)
end
end
end