* 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.
65 lines
2.1 KiB
Ruby
65 lines
2.1 KiB
Ruby
require 'test_helper'
|
|
|
|
class UploadLimitTest < ActiveSupport::TestCase
|
|
context "Upload limits:" do
|
|
setup do
|
|
@user = create(:user, upload_points: 1000, created_at: 2.weeks.ago)
|
|
@approver = create(:moderator_user)
|
|
end
|
|
|
|
context "a pending post that is deleted" do
|
|
should "decrease the uploader's upload points" do
|
|
@post = create(:post, uploader: @user, is_pending: true, created_at: 7.days.ago)
|
|
assert_equal(1000, @user.reload.upload_points)
|
|
|
|
PostPruner.prune!
|
|
assert_equal(967, @user.reload.upload_points)
|
|
end
|
|
end
|
|
|
|
context "a pending post that is approved" do
|
|
should "increase the uploader's upload points" do
|
|
@post = create(:post, uploader: @user, is_pending: true, created_at: 7.days.ago)
|
|
assert_equal(1000, @user.reload.upload_points)
|
|
|
|
@post.approve!(@approver)
|
|
assert_equal(1010, @user.reload.upload_points)
|
|
end
|
|
|
|
should "not increase the uploader's upload points beyond the maximum" do
|
|
@user.update!(upload_points: UploadLimit::MAXIMUM_POINTS)
|
|
|
|
@post = create(:post, uploader: @user, is_pending: true, created_at: 7.days.ago)
|
|
assert_equal(UploadLimit::MAXIMUM_POINTS, @user.reload.upload_points)
|
|
|
|
@post.approve!(@approver)
|
|
assert_equal(UploadLimit::MAXIMUM_POINTS, @user.reload.upload_points)
|
|
end
|
|
end
|
|
|
|
context "an approved post that is deleted" do
|
|
should "decrease the uploader's upload points" do
|
|
@post = create(:post, uploader: @user, is_pending: true)
|
|
assert_equal(1000, @user.reload.upload_points)
|
|
|
|
@post.approve!(@approver)
|
|
assert_equal(1010, @user.reload.upload_points)
|
|
|
|
as(@approver) { @post.delete!("bad") }
|
|
assert_equal(967, @user.reload.upload_points)
|
|
end
|
|
end
|
|
|
|
context "a deleted post that is undeleted" do
|
|
should "increase the uploader's upload points" do
|
|
@post = create(:post, uploader: @user)
|
|
as(@approver) { @post.delete!("bad") }
|
|
assert_equal(967, @user.reload.upload_points)
|
|
|
|
@post.approve!(@approver)
|
|
assert_equal(1010, @user.reload.upload_points)
|
|
end
|
|
end
|
|
end
|
|
end
|