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:
@@ -34,7 +34,22 @@ class ForumPostVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
should "show the vote to all users" do
|
||||
@forum_post_vote = create(:forum_post_vote, forum_post: @forum_post)
|
||||
get forum_post_vote_path(@forum_post_vote), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "work for a JSON response" do
|
||||
post_auth forum_post_votes_path, @user, params: { forum_post_id: @forum_post.id, forum_post_vote: { score: 1 }}, as: :json
|
||||
|
||||
assert_response 201
|
||||
assert_equal(1, @forum_post.votes.count)
|
||||
end
|
||||
|
||||
should "allow members to vote" do
|
||||
assert_difference("ForumPostVote.count", 1) do
|
||||
post_auth forum_post_votes_path(format: :js), @user, params: { forum_post_id: @forum_post.id, forum_post_vote: { score: 1 }}
|
||||
|
||||
Reference in New Issue
Block a user