Use respond_to
This commit is contained in:
parent
f558b61298
commit
04feada77e
2 changed files with 15 additions and 7 deletions
|
@ -74,21 +74,27 @@ class Admin::ProceduresController < AdminController
|
||||||
flash.notice = "Démarche publiée"
|
flash.notice = "Démarche publiée"
|
||||||
render js: "window.location='#{admin_procedures_path}'"
|
render js: "window.location='#{admin_procedures_path}'"
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
render 'publish_validate', formats: :js
|
respond_to do |format|
|
||||||
|
format.js { render :publish_validate }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def transfer
|
def transfer
|
||||||
admin = Administrateur.by_email(params[:email_admin].downcase)
|
admin = Administrateur.by_email(params[:email_admin].downcase)
|
||||||
|
|
||||||
if admin.nil?
|
if admin.nil?
|
||||||
render '/admin/procedures/transfer', formats: 'js', status: 404
|
respond_to do |format|
|
||||||
|
format.js { render :transfer, status: :not_found }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||||
procedure.clone(admin, false)
|
procedure.clone(admin, false)
|
||||||
|
|
||||||
flash.now.notice = "La démarche a correctement été clonée vers le nouvel administrateur."
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
context 'when admin is the owner of the procedure' do
|
context 'when admin is the owner of the procedure' do
|
||||||
before 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
|
procedure.reload
|
||||||
procedure2.reload
|
procedure2.reload
|
||||||
end
|
end
|
||||||
|
@ -246,7 +246,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
sign_out(admin.user)
|
sign_out(admin.user)
|
||||||
sign_in(admin_2.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
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
context 'when the admin does not provide a lien_site_web' do
|
context 'when the admin does not provide a lien_site_web' do
|
||||||
before 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
|
procedure.reload
|
||||||
end
|
end
|
||||||
context 'procedure path is valid but lien_site_web is missing' do
|
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
|
describe 'POST #transfer' do
|
||||||
let!(:procedure) { create :procedure, :with_service, administrateur: admin }
|
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
|
context 'when admin is unknow' do
|
||||||
let(:email_admin) { 'plop' }
|
let(:email_admin) { 'plop' }
|
||||||
|
|
Loading…
Reference in a new issue