feat(contact): delete contact forms when max attempts has been reached
This commit is contained in:
parent
4b48ee02cd
commit
eaa3350b77
2 changed files with 20 additions and 0 deletions
|
@ -25,6 +25,10 @@ class HelpscoutCreateConversationJob < ApplicationJob
|
|||
create_conversation
|
||||
|
||||
contact_form.delete
|
||||
rescue StandardError
|
||||
contact_form.delete if executions >= max_attempts
|
||||
|
||||
raise
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -110,5 +110,21 @@ RSpec.describe HelpscoutCreateConversationJob, type: :job do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when max attempts are reached' do
|
||||
before do
|
||||
allow(api).to receive(:create_conversation).and_raise(StandardError)
|
||||
allow_any_instance_of(described_class).to receive(:executions).and_return(described_class.new.max_attempts)
|
||||
end
|
||||
|
||||
it 'deletes the contact form' do
|
||||
expect { subject }.to raise_error(StandardError)
|
||||
expect(contact_form).to be_destroyed
|
||||
end
|
||||
|
||||
it 'does not enqueue the job again' do
|
||||
expect { subject rescue nil }.not_to have_enqueued_job(described_class)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue