* 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.
71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
require 'test_helper'
|
|
|
|
class PostApprovalsControllerTest < ActionDispatch::IntegrationTest
|
|
context "The post approvals controller" do
|
|
setup do
|
|
@approver = create(:approver)
|
|
end
|
|
|
|
context "create action" do
|
|
context "for a pending post" do
|
|
should "approve the post" do
|
|
@post = create(:post, is_pending: true)
|
|
post_auth post_approvals_path(post_id: @post.id, format: :js), @approver
|
|
|
|
assert_response :success
|
|
assert(!@post.reload.is_pending?)
|
|
end
|
|
end
|
|
|
|
context "for a deleted post" do
|
|
should "undelete the post" do
|
|
@post = create(:post, is_deleted: true)
|
|
post_auth post_approvals_path(post_id: @post.id, format: :js), @approver
|
|
|
|
assert_response :success
|
|
assert(!@post.reload.is_deleted?)
|
|
end
|
|
end
|
|
|
|
context "for an appealed post" do
|
|
should "undelete the post and mark the appeal as successful" do
|
|
@appeal = create(:post_appeal)
|
|
post_auth post_approvals_path(post_id: @appeal.post_id, format: :js), @approver
|
|
|
|
assert_response :success
|
|
assert_equal(false, @appeal.reload.post.is_deleted?)
|
|
assert_equal(true, @appeal.succeeded?)
|
|
end
|
|
end
|
|
|
|
context "for a flagged post" do
|
|
should "approve the post and mark the flag as rejected" do
|
|
@flag = create(:post_flag)
|
|
post_auth post_approvals_path(post_id: @flag.post_id, format: :js), @approver
|
|
|
|
assert_response :success
|
|
assert_equal(false, @flag.reload.post.is_deleted?)
|
|
assert_equal(false, @flag.post.is_flagged?)
|
|
assert_equal(true, @flag.rejected?)
|
|
end
|
|
end
|
|
|
|
should "not allow non-approvers to approve posts" do
|
|
@post = create(:post, is_pending: true)
|
|
post_auth post_approvals_path(post_id: @post.id, format: :js), create(:user)
|
|
|
|
assert_response 403
|
|
assert_equal(true, @post.reload.is_pending?)
|
|
end
|
|
end
|
|
|
|
context "index action" do
|
|
should "render" do
|
|
@approval = create(:post_approval)
|
|
get post_approvals_path
|
|
assert_response :success
|
|
end
|
|
end
|
|
end
|
|
end
|