Assign a procedure assign a group as well
This commit is contained in:
parent
97884c4349
commit
25991c2892
2 changed files with 8 additions and 1 deletions
|
@ -53,7 +53,10 @@ class Instructeur < ApplicationRecord
|
|||
|
||||
def assign_to_procedure(procedure)
|
||||
begin
|
||||
procedures << procedure
|
||||
assign_to.create({
|
||||
procedure: procedure,
|
||||
groupe_instructeur: procedure.defaut_groupe_instructeur
|
||||
})
|
||||
true
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
false
|
||||
|
|
|
@ -97,6 +97,10 @@ describe Instructeur, type: :model do
|
|||
|
||||
it { is_expected.to be_truthy }
|
||||
it { expect { subject }.to change(instructeur.procedures, :count) }
|
||||
it do
|
||||
subject
|
||||
expect(instructeur.groupe_instructeurs).to include(procedure_to_assign.defaut_groupe_instructeur)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an already assigned procedure" do
|
||||
|
|
Loading…
Reference in a new issue