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:
gregoirenovel 2018-12-26 21:22:27 +01:00 committed by GitHub
commit 2f522a7966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

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

View file

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

View file

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