diff --git a/app/logical/upload_limit.rb b/app/logical/upload_limit.rb index e001e7512..05baa35b2 100644 --- a/app/logical/upload_limit.rb +++ b/app/logical/upload_limit.rb @@ -4,6 +4,7 @@ class UploadLimit INITIAL_POINTS = 1000 MAXIMUM_POINTS = 10_000 APPEAL_COST = 3 + DELETION_COST = 5 attr_reader :user @@ -40,7 +41,7 @@ class UploadLimit appealed_count = user.post_appeals.pending.count early_deleted_count = user.posts.deleted.where("created_at >= ?", Danbooru.config.moderation_period.ago).count - pending_count + early_deleted_count + (appealed_count * APPEAL_COST) + pending_count + (early_deleted_count * DELETION_COST) + (appealed_count * APPEAL_COST) end def free_upload_slots diff --git a/test/unit/upload_limit_test.rb b/test/unit/upload_limit_test.rb index 06127b4fb..7f6d7a052 100644 --- a/test/unit/upload_limit_test.rb +++ b/test/unit/upload_limit_test.rb @@ -17,6 +17,14 @@ class UploadLimitTest < ActiveSupport::TestCase end end + context "a new post that is deleted within the first 3 days" do + should "cost the uploader 5 upload slots" do + @post = create(:post, uploader: @user, is_deleted: true, created_at: 1.days.ago) + + assert_equal(5, @user.upload_limit.used_upload_slots) + 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)