Merge pull request #3224 from maatinito/issue/2575_current_gestionnaire_always_assigned_to_new_proc
[Fix #2575] Chaque admin est automatiquement affecté à ses démarches
This commit is contained in:
commit
2f522a7966
3 changed files with 17 additions and 3 deletions
|
@ -71,6 +71,10 @@ class Admin::ProceduresController < AdminController
|
||||||
render 'new'
|
render 'new'
|
||||||
else
|
else
|
||||||
flash.notice = 'Démarche enregistrée.'
|
flash.notice = 'Démarche enregistrée.'
|
||||||
|
gestionnaire = Gestionnaire.find_by(email: current_administrateur.email)
|
||||||
|
if gestionnaire
|
||||||
|
gestionnaire.assign_to_procedure(@procedure)
|
||||||
|
end
|
||||||
redirect_to admin_procedure_types_de_champ_path(procedure_id: @procedure.id)
|
redirect_to admin_procedure_types_de_champ_path(procedure_id: @procedure.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
= f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email'
|
= f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email'
|
||||||
%br
|
|
||||||
.alert.alert-info
|
|
||||||
Astuce : ajoutez votre adresse email pour tester la partie instructeur.
|
|
||||||
.col-xs-6
|
.col-xs-6
|
||||||
%h3.text-success Affectés
|
%h3.text-success Affectés
|
||||||
= smart_listing_render :instructeurs_assign
|
= smart_listing_render :instructeurs_assign
|
||||||
|
|
|
@ -197,6 +197,19 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it { expect(flash[:notice]).to be_present }
|
it { expect(flash[:notice]).to be_present }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when procedure is correctly saved' do
|
||||||
|
let!(:gestionnaire) { create(:gestionnaire, email: admin.email) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
post :create, params: { procedure: procedure_params }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "admin can also instruct the procedure as a gestionnaire" do
|
||||||
|
subject { Procedure.last }
|
||||||
|
it { expect(subject.gestionnaires).to include(gestionnaire) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when many attributs are not valid' do
|
context 'when many attributs are not valid' do
|
||||||
|
|
Loading…
Reference in a new issue