Procedure: remove direct instructeurs access

Add shortcut for the spec to assign instructeurs directly to the defaut groupe
This commit is contained in:
simon lehericey 2019-08-21 14:25:21 +02:00
parent b541ef0b41
commit 31cb056351
2 changed files with 5 additions and 2 deletions

View file

@ -14,10 +14,8 @@ class Procedure < ApplicationRecord
belongs_to :parent_procedure, class_name: 'Procedure'
belongs_to :service
has_many :assign_to, dependent: :destroy
has_many :administrateurs_procedures
has_many :administrateurs, through: :administrateurs_procedures, after_remove: -> (procedure, _admin) { procedure.validate! }
has_many :instructeurs, through: :assign_to
has_many :groupe_instructeurs, dependent: :destroy
has_one :initiated_mail, class_name: "Mails::InitiatedMail", dependent: :destroy

View file

@ -14,6 +14,7 @@ FactoryBot.define do
transient do
administrateur {}
instructeurs { [] }
end
after(:build) do |procedure, evaluator|
@ -24,6 +25,10 @@ FactoryBot.define do
end
end
after(:create) do |procedure, evaluator|
evaluator.instructeurs.each { |i| i.assign_to_procedure(procedure) }
end
factory :procedure_with_dossiers do
transient do
dossiers_count { 1 }