Merge pull request #10675 from colinux/fix-contact-form-deletion
Tech: permet la suppression des ContactForm d'users ayant des dossiers
This commit is contained in:
commit
9d1bc790cf
3 changed files with 17 additions and 2 deletions
|
@ -22,7 +22,7 @@ class HelpscoutCreateConversationJob < ApplicationJob
|
|||
|
||||
create_conversation
|
||||
|
||||
contact_form.destroy
|
||||
contact_form.delete
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ContactForm < ApplicationRecord
|
||||
attr_reader :options
|
||||
|
||||
belongs_to :user, optional: true, dependent: :destroy
|
||||
belongs_to :user, optional: true
|
||||
|
||||
after_initialize :set_options
|
||||
before_validation :normalize_strings
|
||||
|
|
|
@ -91,6 +91,21 @@ RSpec.describe HelpscoutCreateConversationJob, type: :job do
|
|||
it 'associates the email from user' do
|
||||
subject
|
||||
expect(api).to have_received(:create_conversation).with(user.email, subject_text, text, nil)
|
||||
expect(contact_form).to be_destroyed
|
||||
expect(user.reload).to be_truthy
|
||||
end
|
||||
|
||||
context 'having dossiers' do
|
||||
before do
|
||||
create(:dossier, user:)
|
||||
end
|
||||
|
||||
it 'associates the email from user' do
|
||||
subject
|
||||
expect(api).to have_received(:create_conversation).with(user.email, subject_text, text, nil)
|
||||
expect(contact_form).to be_destroyed
|
||||
expect(user.reload).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue