appeals: raise appeal limits.

The old limit was one appeal per day. The new limit is based on your
upload limit. Each appeal costs 3 upload slots. If you have 15 upload
slots, then you can appeal up to 5 posts at once, but you won't be able
to appeal or upload more until your appeals are approved or rejected. If
you have unlimited uploads, then you have unlimited appeals.
This commit is contained in:
evazion
2020-08-08 10:37:51 -05:00
parent 3a17b5a13e
commit e8dcc9c56e
4 changed files with 48 additions and 31 deletions

View File

@@ -3,37 +3,55 @@ require 'test_helper'
class PostAppealTest < ActiveSupport::TestCase
context "In all cases" do
setup do
@alice = create(:user)
@user = create(:user, upload_points: 1000)
end
context "a user" do
setup do
@post = FactoryBot.create(:post, :tag_string => "aaa", :is_deleted => true)
@post = create(:post, tag_string: "aaa", is_deleted: true)
end
should "not be able to appeal a post more than twice" do
@post_appeal = create(:post_appeal, post: @post, creator: @alice)
@post_appeal = build(:post_appeal, post: @post, creator: @alice)
should "not be able to appeal a post more than once" do
@post_appeal = create(:post_appeal, post: @post, creator: @user)
@post_appeal = build(:post_appeal, post: @post, creator: @user)
assert_equal(false, @post_appeal.valid?)
assert_includes(@post_appeal.errors.full_messages, "You have already appealed this post")
end
should "not be able to appeal more than 1 post in 24 hours" do
@post_appeal = create(:post_appeal, post: @post, creator: @alice)
@post_appeal = build(:post_appeal, post: create(:post, is_deleted: true), creator: @alice)
assert_equal(false, @post_appeal.valid?)
assert_equal(["You can appeal at most 1 post a day"], @post_appeal.errors.full_messages)
end
should "not be able to appeal an active post" do
@post.update_attribute(:is_deleted, false)
@post_appeal = build(:post_appeal, post: @post, creator: @alice)
@post.update!(is_deleted: false)
@post_appeal = build(:post_appeal, post: @post, creator: @user)
assert_equal(false, @post_appeal.valid?)
assert_equal(["Post cannot be appealed"], @post_appeal.errors.full_messages)
end
context "appeal limits" do
context "for members" do
should "not be able to appeal more than their upload limit" do
create_list(:post_appeal, 5, creator: @user)
assert_equal(15, @user.upload_limit.upload_slots)
assert_equal(15, @user.upload_limit.used_upload_slots)
@post_appeal = build(:post_appeal, creator: @user)
assert_equal(false, @post_appeal.valid?)
assert_equal(["have reached your appeal limit"], @post_appeal.errors[:creator])
end
end
context "for users with unrestricted uploads" do
should "should not have an appeal limit" do
@user = create(:user, can_upload_free: true)
create_list(:post_appeal, 10, creator: @user)
assert_equal(15, @user.upload_limit.upload_slots)
assert_equal(30, @user.upload_limit.used_upload_slots)
assert_equal(false, @user.is_appeal_limited?)
end
end
end
end
end
end