flags: ignore flagging rate-limits when deleting posts.

This commit is contained in:
evazion
2017-05-17 22:49:52 -05:00
parent 565945ab7b
commit 3570ace017
2 changed files with 18 additions and 7 deletions

View File

@@ -139,10 +139,10 @@ class PostFlag < ActiveRecord::Base
end
def validate_creator_is_not_limited
return if is_deletion
if CurrentUser.can_approve_posts?
# do nothing
elsif User.system.present? && CurrentUser.id == User.system.id
# do nothing
elsif creator.created_at > 1.week.ago
errors[:creator] << "cannot flag within the first week of sign up"
elsif creator.is_gold? && flag_count_for_creator >= 10
@@ -150,11 +150,6 @@ class PostFlag < ActiveRecord::Base
elsif !creator.is_gold? && flag_count_for_creator >= 1
errors[:creator] << "can flag 1 post a day"
end
end
def validate_post
errors[:post] << "is locked and cannot be flagged" if post.is_status_locked?
errors[:post] << "is deleted" if post.is_deleted?
flag = post.flags.in_cooldown.last
if flag.present?
@@ -162,6 +157,11 @@ class PostFlag < ActiveRecord::Base
end
end
def validate_post
errors[:post] << "is locked and cannot be flagged" if post.is_status_locked?
errors[:post] << "is deleted" if post.is_deleted?
end
def initialize_creator
self.creator_id ||= CurrentUser.id
self.creator_ip_addr ||= CurrentUser.ip_addr

View File

@@ -95,6 +95,17 @@ class PostTest < ActiveSupport::TestCase
end
end
context "that is still in cooldown after being flagged" do
should "succeed" do
post = FactoryGirl.create(:post)
post.flag!("test flag")
post.delete!("test deletion")
assert_equal(true, post.is_deleted)
assert_equal(2, post.flags.size)
end
end
should "update the fast count" do
Danbooru.config.stubs(:estimate_post_counts).returns(false)
post = FactoryGirl.create(:post, :tag_string => "aaa")