Assign a procedure assign a group as well

This commit is contained in:
simon lehericey 2019-08-20 16:59:45 +02:00
parent 97884c4349
commit 25991c2892
2 changed files with 8 additions and 1 deletions

View file

@ -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

View file

@ -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