Merge pull request #6741 from tchak/fix-bulk_messages_groupe_instructeurs
fix(bulk_messages): destroy bulk messages with procedures
This commit is contained in:
commit
58adcf14e4
5 changed files with 20 additions and 1 deletions
|
@ -15,6 +15,7 @@ class GroupeInstructeur < ApplicationRecord
|
|||
has_many :instructeurs, through: :assign_tos
|
||||
has_many :dossiers
|
||||
has_and_belongs_to_many :exports, dependent: :destroy
|
||||
has_and_belongs_to_many :bulk_messages, dependent: :destroy
|
||||
|
||||
validates :label, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :label, uniqueness: { scope: :procedure, message: 'existe déjà' }
|
||||
|
|
10
spec/factories/bulk_message.rb
Normal file
10
spec/factories/bulk_message.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
FactoryBot.define do
|
||||
factory :bulk_message do
|
||||
body { 'bonjour' }
|
||||
dossier_count { 1 }
|
||||
dossier_state { Dossier.states.fetch(:brouillon) }
|
||||
sent_at { 1.day.ago }
|
||||
instructeur { association :instructeur }
|
||||
groupe_instructeurs { [association(:groupe_instructeur, strategy: :build)] }
|
||||
end
|
||||
end
|
|
@ -8,5 +8,9 @@ FactoryBot.define do
|
|||
trait :default do
|
||||
label { GroupeInstructeur::DEFAUT_LABEL }
|
||||
end
|
||||
|
||||
trait :with_bulk_message do
|
||||
bulk_messages { [association(:bulk_message, strategy: :build)] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,6 +72,10 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :with_bulk_message do
|
||||
groupe_instructeurs { [association(:groupe_instructeur, :default, :with_bulk_message, procedure: instance, strategy: :build)] }
|
||||
end
|
||||
|
||||
trait :with_logo do
|
||||
logo { Rack::Test::UploadedFile.new('spec/fixtures/files/logo_test_procedure.png', 'image/png') }
|
||||
end
|
||||
|
|
|
@ -1115,7 +1115,7 @@ describe Procedure do
|
|||
end
|
||||
|
||||
describe "#destroy" do
|
||||
let(:procedure) { create(:procedure, :closed, :with_type_de_champ) }
|
||||
let(:procedure) { create(:procedure, :closed, :with_type_de_champ, :with_bulk_message) }
|
||||
|
||||
before do
|
||||
procedure.discard!
|
||||
|
|
Loading…
Reference in a new issue