* Include appealed posts in the modqueue. * Add `status` field to appeals. Appeals start out as `pending`, then become `rejected` if the post isn't approved within three days. If the post is approved, the appeal's status becomes `succeeded`. * Add `status` field to flags. Flags start out as `pending` then become `rejected` if the post is approved within three days. If the post isn't approved, the flag's status becomes `succeeded`. * Leave behind a "Unapproved in three days" dummy flag when an appeal goes unapproved, just like when a pending post is unapproved. * Only allow deleted posts to be appealed. Don't allow flagged posts to be appealed. * Add `status:appealed` metatag. `status:appealed` is separate from `status:pending`. * Include appealed posts in `status:modqueue`. Search `status:modqueue order:modqueue` to view the modqueue as a normal search. * Retroactively set old flags and appeals as succeeded or rejected. This may not be correct for posts that were appealed or flagged multiple times. This is difficult to set correctly because we don't have approval records for old posts, so we can't tell the actual outcome of old flags and appeals. * Deprecate the `is_resolved` field on post flags. A resolved flag is a flag that isn't pending. * Known bug: appealed posts have a black border instead of a blue border. Checking whether a post has been appealed would require either an extra query on the posts/index page, or an is_appealed flag on posts, neither of which are very desirable. * Known bug: you can't use `status:appealed` in blacklists, for the same reason as above.
104 lines
2.9 KiB
Ruby
104 lines
2.9 KiB
Ruby
require 'test_helper'
|
|
|
|
class PostAppealsControllerTest < ActionDispatch::IntegrationTest
|
|
context "The post appeals controller" do
|
|
setup do
|
|
@user = create(:user)
|
|
end
|
|
|
|
context "new action" do
|
|
should "render" do
|
|
get_auth new_post_appeal_path, @user
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "show action" do
|
|
should "render" do
|
|
@appeal = create(:post_appeal)
|
|
get post_appeal_path(@appeal)
|
|
assert_redirected_to post_appeals_path(search: { id: @appeal.id })
|
|
end
|
|
end
|
|
|
|
context "index action" do
|
|
setup do
|
|
as(@user) do
|
|
@post = create(:post, :is_deleted => true)
|
|
@post_appeal = create(:post_appeal, :post => @post)
|
|
end
|
|
end
|
|
|
|
should "render" do
|
|
get_auth post_appeals_path, @user
|
|
assert_response :success
|
|
end
|
|
|
|
should "render for json" do
|
|
get post_appeals_path, as: :json
|
|
assert_response :success
|
|
end
|
|
|
|
context "with search parameters" do
|
|
should "render" do
|
|
get_auth post_appeals_path, @user, params: {:search => {:post_id => @post_appeal.post_id}}
|
|
assert_response :success
|
|
end
|
|
end
|
|
end
|
|
|
|
context "create action" do
|
|
context "appealing a deleted post" do
|
|
should "create a new appeal" do
|
|
@post = create(:post, is_deleted: true)
|
|
|
|
assert_difference("PostAppeal.count", 1) do
|
|
post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @post.id, reason: "xxx" }}, as: :json
|
|
end
|
|
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "appealing a flagged post" do
|
|
should "fail" do
|
|
@flag = create(:post_flag)
|
|
|
|
assert_no_difference("PostAppeal.count") do
|
|
post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @flag.post.id, reason: "xxx" }}, as: :json
|
|
end
|
|
|
|
assert_response 422
|
|
assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
|
|
end
|
|
end
|
|
|
|
context "appealing a pending post" do
|
|
should "fail" do
|
|
@post = create(:post, is_pending: true)
|
|
|
|
assert_no_difference("PostAppeal.count") do
|
|
post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @post.id, reason: "xxx" }}, as: :json
|
|
end
|
|
|
|
assert_response 422
|
|
assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
|
|
end
|
|
end
|
|
|
|
context "appealing an already appealed post" do
|
|
should "fail" do
|
|
@appeal = create(:post_appeal)
|
|
|
|
assert_no_difference("PostAppeal.count") do
|
|
post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @appeal.post.id, reason: "xxx" }}, as: :json
|
|
end
|
|
|
|
assert_response 422
|
|
assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|