tests: fixup post votes, comment votes controller tests.
This commit is contained in:
@@ -17,7 +17,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "#create.json" do
|
context "#create.json" do
|
||||||
should "create a vote" do
|
should "create a vote" do
|
||||||
assert_difference("CommentVote.count", 1) do
|
assert_difference("CommentVote.count", 1) do
|
||||||
post_auth comment_votes_path(comment_id: @comment.id, score: "down"), @user, as: :json
|
post_auth comment_comment_votes_path(comment_id: @comment.id, score: "down"), @user, as: :json
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_equal(@comment.id, response.parsed_body["id"])
|
assert_equal(@comment.id, response.parsed_body["id"])
|
||||||
@@ -28,7 +28,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
should "fail silently on errors" do
|
should "fail silently on errors" do
|
||||||
create(:comment_vote, comment: @comment, score: -1)
|
create(:comment_vote, comment: @comment, score: -1)
|
||||||
assert_difference("CommentVote.count", 0) do
|
assert_difference("CommentVote.count", 0) do
|
||||||
post_auth comment_votes_path(comment_id: @comment.id, score: "down", format: "json"), @user
|
post_auth comment_comment_votes_path(comment_id: @comment.id, score: "down", format: "json"), @user
|
||||||
assert_response 422
|
assert_response 422
|
||||||
|
|
||||||
comment = JSON.parse(@response.body)
|
comment = JSON.parse(@response.body)
|
||||||
@@ -41,7 +41,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "#create.js" do
|
context "#create.js" do
|
||||||
should "create a vote" do
|
should "create a vote" do
|
||||||
assert_difference("CommentVote.count", 1) do
|
assert_difference("CommentVote.count", 1) do
|
||||||
post_auth comment_votes_path(comment_id: @comment.id, format: "json", score: "down"), @user
|
post_auth comment_comment_votes_path(comment_id: @comment.id, format: "json", score: "down"), @user
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -49,7 +49,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
should "fail on errors" do
|
should "fail on errors" do
|
||||||
create(:comment_vote, :comment => @comment, :score => -1)
|
create(:comment_vote, :comment => @comment, :score => -1)
|
||||||
assert_difference("CommentVote.count", 0) do
|
assert_difference("CommentVote.count", 0) do
|
||||||
post_auth comment_votes_path(comment_id: @comment.id, :score => "down", format: "js"), @user
|
post_auth comment_comment_votes_path(comment_id: @comment.id, :score => "down", format: "js"), @user
|
||||||
assert_response 422
|
assert_response 422
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class PostVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "index action" do
|
context "index action" do
|
||||||
should "work" do
|
should "work" do
|
||||||
as(@user) { create(:post_vote, post_id: @post.id, user_id: @user.id) }
|
as(@user) { create(:post_vote, post_id: @post.id, user_id: @user.id) }
|
||||||
get post_votes_path
|
get_auth post_votes_path, @user
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user