post votes: fix exception when voting on posts using API.
Fix an `undefined method post_vote_url` exception when doing `POST https://danbooru.donmai.us/posts/1/votes.json`. Also add the following API endpoints: * https://danbooru.donmai.us/post_votes/:id.json * https://danbooru.donmai.us/comment_votes/:id.json * https://danbooru.donmai.us/forum_post_votes/:id.json where `:id` is the vote ID, not the post ID.
This commit is contained in:
@@ -53,12 +53,40 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
@comment_vote = create(:comment_vote, comment: @comment, user: @user)
|
||||
end
|
||||
|
||||
should "show the vote to the voter" do
|
||||
get_auth comment_vote_path(@comment_vote), @user, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "show the vote to moderators" do
|
||||
get_auth comment_vote_path(@comment_vote), create(:moderator_user), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "not show the vote to other users" do
|
||||
get_auth comment_vote_path(@comment_vote), create(:user), as: :json
|
||||
assert_response 403
|
||||
end
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
setup do
|
||||
@user = create(:user)
|
||||
@comment = create(:comment)
|
||||
end
|
||||
|
||||
should "work for a JSON response" do
|
||||
post_auth comment_comment_votes_path(comment_id: @comment.id), @user, params: { score: 1, format: "json" }
|
||||
|
||||
assert_response 201
|
||||
assert_equal(1, @comment.reload.score)
|
||||
end
|
||||
|
||||
should "not allow anonymous users to vote" do
|
||||
post comment_comment_votes_path(comment_id: @comment.id, score: "1"), xhr: true
|
||||
assert_response 403
|
||||
|
||||
Reference in New Issue
Block a user