forked from forem/forem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete old retained emails after certain period (forem#14949)
* Delete old retained emails after certain period * Update app/models/email_message.rb Co-authored-by: Jamie Gaskins <[email protected]> * Update spec/workers/emails/remove_old_emails_worker_spec.rb Co-authored-by: Jamie Gaskins <[email protected]> * Update app/models/email_message.rb Co-authored-by: Jamie Gaskins <[email protected]> Co-authored-by: Jamie Gaskins <[email protected]>
- Loading branch information
1 parent
3a4a273
commit 549336b
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Emails | ||
class RemoveOldEmailsWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: :low_priority, retry: 10 | ||
|
||
def perform | ||
EmailMessage.fast_destroy_old_retained_email_deliveries | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Emails::RemoveOldEmailsWorker, type: :worker do | ||
include_examples "#enqueues_on_correct_queue", "low_priority" | ||
|
||
describe "#perform" do | ||
let(:worker) { subject } | ||
|
||
it "fast destroys notifications" do | ||
allow(EmailMessage).to receive(:fast_destroy_old_retained_email_deliveries) | ||
worker.perform | ||
expect(EmailMessage).to have_received(:fast_destroy_old_retained_email_deliveries) | ||
end | ||
end | ||
end |