docbrown/spec/models/email_message_spec.rb
Ben Halpern 549336b0a2
Delete old retained emails after certain period (#14949)
* Delete old retained emails after certain period

* Update app/models/email_message.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update spec/workers/emails/remove_old_emails_worker_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/models/email_message.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

Co-authored-by: Jamie Gaskins <jamie@forem.com>
2021-10-12 16:27:13 -04:00

17 lines
570 B
Ruby

require "rails_helper"
RSpec.describe EmailMessage, type: :model do
describe "validations" do
subject { create(:email_message) }
it { is_expected.to belong_to(:feedback_message).optional }
end
describe "#fast_destroy_old_notifications" do
it "bulk deletes emails older than given timestamp" do
allow(BulkSqlDelete).to receive(:delete_in_batches)
described_class.fast_destroy_old_retained_email_deliveries("a_time")
expect(BulkSqlDelete).to have_received(:delete_in_batches).with(a_string_including("< 'a_time'"))
end
end
end