chore: Destroy account inboxes asynchronously
This commit is contained in:
parent
26f36548c2
commit
10a13c3f5c
2 changed files with 19 additions and 2 deletions
|
@ -38,7 +38,7 @@ class Account < ApplicationRecord
|
|||
has_many :csat_survey_responses, dependent: :destroy
|
||||
has_many :data_imports, dependent: :destroy
|
||||
has_many :users, through: :account_users
|
||||
has_many :inboxes, dependent: :destroy
|
||||
has_many :inboxes, dependent: :destroy_async
|
||||
has_many :notes, dependent: :destroy
|
||||
has_many :campaigns, dependent: :destroy
|
||||
has_many :conversations, dependent: :destroy
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Account do
|
|||
|
||||
it { is_expected.to have_many(:users).through(:account_users) }
|
||||
it { is_expected.to have_many(:account_users) }
|
||||
it { is_expected.to have_many(:inboxes).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:inboxes).dependent(:destroy_async) }
|
||||
it { is_expected.to have_many(:conversations).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:contacts).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:telegram_bots).dependent(:destroy) }
|
||||
|
@ -21,4 +21,21 @@ RSpec.describe Account do
|
|||
it { is_expected.to have_many(:kbase_portals).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:kbase_categories).dependent(:destroy) }
|
||||
it { is_expected.to have_many(:teams).dependent(:destroy) }
|
||||
|
||||
context 'when destroy async' do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
it 'Associated inboxes' do
|
||||
account = FactoryBot.create(:account)
|
||||
FactoryBot.create(:inbox, account: account)
|
||||
|
||||
expect(account.inboxes.count).to be(1)
|
||||
|
||||
account.destroy
|
||||
|
||||
assert_enqueued_jobs 2
|
||||
|
||||
expect(account.inboxes.count).to be(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue