Fix failures in commenting tests.
Restricting users from upvoting their own comments broke some tests. Switch these tests to downvoting instead.
This commit is contained in:
@@ -24,9 +24,9 @@ class CommentVotesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "fail silently on errors" do
|
should "fail silently on errors" do
|
||||||
FactoryGirl.create(:comment_vote, :comment => @comment)
|
FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1)
|
||||||
assert_difference("CommentVote.count", 0) do
|
assert_difference("CommentVote.count", 0) do
|
||||||
post :create, {:format => "json", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
|
post :create, {:format => "json", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id}
|
||||||
assert_response 422
|
assert_response 422
|
||||||
assert_equal("{\"errors\":{\"user_id\":[\"have already voted for this comment\"]}}", @response.body.strip)
|
assert_equal("{\"errors\":{\"user_id\":[\"have already voted for this comment\"]}}", @response.body.strip)
|
||||||
end
|
end
|
||||||
@@ -42,9 +42,9 @@ class CommentVotesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "fail silently on errors" do
|
should "fail silently on errors" do
|
||||||
FactoryGirl.create(:comment_vote, :comment => @comment)
|
FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1)
|
||||||
assert_difference("CommentVote.count", 0) do
|
assert_difference("CommentVote.count", 0) do
|
||||||
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
|
post :create, {:format => "js", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
dmail = Dmail.last
|
dmail = Dmail.last
|
||||||
assert_equal("You were mentioned in a \"comment\":http://#{Danbooru.config.hostname}/posts/#{@comment.post_id}#comment-#{@comment.id}\n\n---\n\n[i]#{CurrentUser.name} said:[/i]\n\nHey @#{@user2.name} check this out!", dmail.body)
|
assert_equal("You were mentioned in a \"comment\":/posts/#{@comment.post_id}#comment-#{@comment.id}\n\n---\n\n[i]#{CurrentUser.name} said:[/i]\n\nHey @#{@user2.name} check this out!", dmail.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
assert(@user.can_comment_vote?)
|
assert(@user.can_comment_vote?)
|
||||||
10.times do
|
10.times do
|
||||||
comment = FactoryGirl.create(:comment)
|
comment = FactoryGirl.create(:comment)
|
||||||
FactoryGirl.create(:comment_vote, :comment_id => comment.id)
|
FactoryGirl.create(:comment_vote, :comment_id => comment.id, :score => -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(!@user.can_comment_vote?)
|
assert(!@user.can_comment_vote?)
|
||||||
|
|||||||
Reference in New Issue
Block a user