mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 15:13:43 +08:00
Delete all posts is allowed for the same amount of time as delete user
This commit is contained in:
parent
9782d3777e
commit
b8a1e21dbd
|
@ -203,7 +203,7 @@ class Guardian
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_delete_all_posts?(user)
|
def can_delete_all_posts?(user)
|
||||||
is_staff? && user && !user.admin? && user.created_at >= 7.days.ago && user.post_count <= SiteSetting.delete_all_posts_max.to_i
|
is_staff? && user && !user.admin? && user.created_at >= SiteSetting.delete_user_max_age.days.ago && user.post_count <= SiteSetting.delete_all_posts_max.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_remove_allowed_users?(topic)
|
def can_remove_allowed_users?(topic)
|
||||||
|
|
|
@ -1045,12 +1045,14 @@ describe Guardian do
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples "can_delete_all_posts examples" do
|
shared_examples "can_delete_all_posts examples" do
|
||||||
it "is true if user is newer than 7 days old" do
|
it "is true if user is newer than delete_user_max_age days old" do
|
||||||
Guardian.new(actor).can_delete_all_posts?(Fabricate.build(:user, created_at: 6.days.ago)).should be_true
|
SiteSetting.expects(:delete_user_max_age).returns(10)
|
||||||
|
Guardian.new(actor).can_delete_all_posts?(Fabricate.build(:user, created_at: 9.days.ago)).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is false if user is older than 7 days old" do
|
it "is false if user is older than delete_user_max_age days old" do
|
||||||
Guardian.new(actor).can_delete_all_posts?(Fabricate.build(:user, created_at: 8.days.ago)).should be_false
|
SiteSetting.expects(:delete_user_max_age).returns(10)
|
||||||
|
Guardian.new(actor).can_delete_all_posts?(Fabricate.build(:user, created_at: 11.days.ago)).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is false if user is an admin" do
|
it "is false if user is an admin" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user