2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-21 04:17:08 -04:00
|
|
|
RSpec.describe Jobs::CleanUpPostReplyKeys do
|
|
|
|
it 'removes old post_reply_keys' do
|
|
|
|
freeze_time
|
|
|
|
|
|
|
|
reply_key1 = Fabricate(:post_reply_key, created_at: 1.day.ago)
|
|
|
|
reply_key2 = Fabricate(:post_reply_key, created_at: 2.days.ago)
|
|
|
|
Fabricate(:post_reply_key, created_at: 3.days.ago)
|
|
|
|
|
|
|
|
SiteSetting.disallow_reply_by_email_after_days = 0
|
|
|
|
|
|
|
|
expect { Jobs::CleanUpPostReplyKeys.new.execute({}) }
|
2022-07-19 10:03:03 -04:00
|
|
|
.not_to change { PostReplyKey.count }
|
2018-08-21 04:17:08 -04:00
|
|
|
|
|
|
|
SiteSetting.disallow_reply_by_email_after_days = 2
|
|
|
|
|
|
|
|
expect { Jobs::CleanUpPostReplyKeys.new.execute({}) }
|
|
|
|
.to change { PostReplyKey.count }.by(-1)
|
|
|
|
|
|
|
|
expect(PostReplyKey.all).to contain_exactly(
|
|
|
|
reply_key1, reply_key2
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|