Add site setting delete_removed_posts_after to configure after how many hour posts that were deleted by their authors will be deleted

This commit is contained in:
Neil Lalonde
2013-08-02 13:35:42 -04:00
parent ef82b66e95
commit 9db0ac16a9
8 changed files with 49 additions and 7 deletions

View File

@ -13,6 +13,7 @@ describe PostDestroyer do
describe 'destroy_old_stubs' do
it 'destroys stubs for deleted by user posts' do
SiteSetting.stubs(:delete_removed_posts_after).returns(24)
Fabricate(:admin)
topic = post.topic
reply1 = create_post(topic: topic)
@ -53,6 +54,42 @@ describe PostDestroyer do
reply1.deleted_at.should == nil
end
it 'uses the delete_removed_posts_after site setting' do
Fabricate(:admin)
topic = post.topic
reply1 = create_post(topic: topic)
reply2 = create_post(topic: topic)
PostDestroyer.new(reply1.user, reply1).destroy
PostDestroyer.new(reply2.user, reply2).destroy
SiteSetting.stubs(:delete_removed_posts_after).returns(1)
reply2.update_column(:updated_at, 70.minutes.ago)
PostDestroyer.destroy_stubs
reply1.reload
reply2.reload
reply1.deleted_at.should == nil
reply2.deleted_at.should_not == nil
SiteSetting.stubs(:delete_removed_posts_after).returns(72)
reply1.update_column(:updated_at, 2.days.ago)
PostDestroyer.destroy_stubs
reply1.reload.deleted_at.should == nil
SiteSetting.stubs(:delete_removed_posts_after).returns(47)
PostDestroyer.destroy_stubs
reply1.reload.deleted_at.should_not == nil
end
end
describe 'basic destroying' do
@ -65,10 +102,11 @@ describe PostDestroyer do
end
it "doesn't delete the post" do
SiteSetting.stubs(:delete_removed_posts_after).returns(24)
post.deleted_at.should be_blank
post.deleted_by.should be_blank
post.user_deleted.should be_true
post.raw.should == I18n.t('js.post.deleted_by_author')
post.raw.should == I18n.t('js.post.deleted_by_author', {count: 24})
post.version.should == 2
# lets try to recover