chore(bulk messages): update associations
This commit is contained in:
parent
89401d0e30
commit
30f96a79c2
7 changed files with 3 additions and 9 deletions
|
@ -283,7 +283,6 @@ module Instructeurs
|
||||||
dossier_state: Dossier.states.fetch(:brouillon),
|
dossier_state: Dossier.states.fetch(:brouillon),
|
||||||
sent_at: Time.zone.now,
|
sent_at: Time.zone.now,
|
||||||
instructeur_id: current_instructeur.id,
|
instructeur_id: current_instructeur.id,
|
||||||
groupe_instructeurs: GroupeInstructeur.for_dossiers(dossiers),
|
|
||||||
procedure_id: @procedure.id
|
procedure_id: @procedure.id
|
||||||
)
|
)
|
||||||
bulk_message.save!
|
bulk_message.save!
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class BulkMessage < ApplicationRecord
|
class BulkMessage < ApplicationRecord
|
||||||
belongs_to :instructeur
|
belongs_to :instructeur
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
has_and_belongs_to_many :groupe_instructeurs, -> { order(:label) }
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,6 @@ class GroupeInstructeur < ApplicationRecord
|
||||||
has_many :assignments, class_name: 'DossierAssignment', dependent: :nullify, inverse_of: :groupe_instructeur
|
has_many :assignments, class_name: 'DossierAssignment', dependent: :nullify, inverse_of: :groupe_instructeur
|
||||||
has_many :previous_assignments, class_name: 'DossierAssignment', dependent: :nullify, inverse_of: :previous_groupe_instructeur
|
has_many :previous_assignments, class_name: 'DossierAssignment', dependent: :nullify, inverse_of: :previous_groupe_instructeur
|
||||||
has_and_belongs_to_many :exports, dependent: :destroy
|
has_and_belongs_to_many :exports, dependent: :destroy
|
||||||
has_and_belongs_to_many :bulk_messages, dependent: :destroy
|
|
||||||
|
|
||||||
has_one :defaut_procedure, -> { with_discarded }, class_name: 'Procedure', foreign_key: :defaut_groupe_instructeur_id, dependent: :nullify, inverse_of: :defaut_groupe_instructeur
|
has_one :defaut_procedure, -> { with_discarded }, class_name: 'Procedure', foreign_key: :defaut_groupe_instructeur_id, dependent: :nullify, inverse_of: :defaut_groupe_instructeur
|
||||||
has_one :contact_information, dependent: :destroy
|
has_one :contact_information, dependent: :destroy
|
||||||
|
|
|
@ -60,6 +60,8 @@ class Procedure < ApplicationRecord
|
||||||
belongs_to :zone, optional: true
|
belongs_to :zone, optional: true
|
||||||
has_and_belongs_to_many :zones
|
has_and_belongs_to_many :zones
|
||||||
|
|
||||||
|
has_many :bulk_messages, dependent: :destroy
|
||||||
|
|
||||||
def active_dossier_submitted_message
|
def active_dossier_submitted_message
|
||||||
published_dossier_submitted_message || draft_dossier_submitted_message
|
published_dossier_submitted_message || draft_dossier_submitted_message
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,6 @@ FactoryBot.define do
|
||||||
dossier_state { Dossier.states.fetch(:brouillon) }
|
dossier_state { Dossier.states.fetch(:brouillon) }
|
||||||
sent_at { 1.day.ago }
|
sent_at { 1.day.ago }
|
||||||
instructeur { association :instructeur }
|
instructeur { association :instructeur }
|
||||||
groupe_instructeurs { [association(:groupe_instructeur, strategy: :build)] }
|
|
||||||
procedure { association :procedure }
|
procedure { association :procedure }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,9 +12,5 @@ FactoryBot.define do
|
||||||
trait :default do
|
trait :default do
|
||||||
label { GroupeInstructeur::DEFAUT_LABEL }
|
label { GroupeInstructeur::DEFAUT_LABEL }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_bulk_message do
|
|
||||||
bulk_messages { [association(:bulk_message, strategy: :build)] }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,7 +94,7 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_bulk_message do
|
trait :with_bulk_message do
|
||||||
groupe_instructeurs { [association(:groupe_instructeur, :default, :with_bulk_message, procedure: instance, strategy: :build)] }
|
bulk_messages { [create(:bulk_message)] }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_logo do
|
trait :with_logo do
|
||||||
|
|
Loading…
Reference in a new issue