diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 3a38ab35a..827d7542a 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -74,21 +74,27 @@ class Admin::ProceduresController < AdminController flash.notice = "Démarche publiée" render js: "window.location='#{admin_procedures_path}'" rescue ActiveRecord::RecordInvalid - render 'publish_validate', formats: :js + respond_to do |format| + format.js { render :publish_validate } + end end def transfer admin = Administrateur.by_email(params[:email_admin].downcase) if admin.nil? - render '/admin/procedures/transfer', formats: 'js', status: 404 + respond_to do |format| + format.js { render :transfer, status: :not_found } + end else procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure.clone(admin, false) flash.now.notice = "La démarche a correctement été clonée vers le nouvel administrateur." - render '/admin/procedures/transfer', formats: 'js', status: 200 + respond_to do |format| + format.js + end end end diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index b94145623..c8cf264e8 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -167,7 +167,7 @@ describe Admin::ProceduresController, type: :controller do context 'when admin is the owner of the procedure' do before do - put :publish, format: :js, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web } + put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web }, format: 'js' procedure.reload procedure2.reload end @@ -246,7 +246,7 @@ describe Admin::ProceduresController, type: :controller do sign_out(admin.user) sign_in(admin_2.user) - put :publish, params: { procedure_id: procedure.id, path: 'fake_path' } + put :publish, params: { procedure_id: procedure.id, path: 'fake_path' }, format: 'js' procedure.reload end @@ -257,7 +257,7 @@ describe Admin::ProceduresController, type: :controller do context 'when the admin does not provide a lien_site_web' do before do - put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web } + put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web }, format: 'js' procedure.reload end context 'procedure path is valid but lien_site_web is missing' do @@ -411,7 +411,9 @@ describe Admin::ProceduresController, type: :controller do describe 'POST #transfer' do let!(:procedure) { create :procedure, :with_service, administrateur: admin } - subject { post :transfer, params: { email_admin: email_admin, procedure_id: procedure.id } } + subject do + post :transfer, params: { email_admin: email_admin, procedure_id: procedure.id }, format: 'js' + end context 'when admin is unknow' do let(:email_admin) { 'plop' }