'Services' routes moved under 'new_administrateur' scope and '/admn' added in their url

This commit is contained in:
Judith 2020-07-07 12:31:52 +02:00 committed by jpoulvel (Rebase PR Action)
parent 782706537d
commit 9793128f61
9 changed files with 17 additions and 19 deletions

View file

@ -15,7 +15,7 @@ module NewAdministrateur
@service.administrateur = current_administrateur
if @service.save
redirect_to services_path(procedure_id: params[:procedure_id]),
redirect_to admin_services_path(procedure_id: params[:procedure_id]),
notice: "#{@service.nom} créé"
else
@procedure = procedure
@ -33,7 +33,7 @@ module NewAdministrateur
@service = service
if @service.update(service_params)
redirect_to services_path(procedure_id: params[:procedure_id]),
redirect_to admin_services_path(procedure_id: params[:procedure_id]),
notice: "#{@service.nom} modifié"
else
@procedure = procedure
@ -62,10 +62,10 @@ module NewAdministrateur
message = "les démarches #{service_to_destroy.procedures.map(&:libelle).join(', ')} utilisent encore le service #{service.nom}. Veuillez les affecter à un autre service avant de pouvoir le supprimer"
end
flash[:alert] = message
redirect_to services_path(procedure_id: params[:procedure_id])
redirect_to admin_services_path(procedure_id: params[:procedure_id])
else
service_to_destroy.destroy
redirect_to services_path(procedure_id: params[:procedure_id]),
redirect_to admin_services_path(procedure_id: params[:procedure_id]),
notice: "#{service_to_destroy.nom} est supprimé"
end
end

View file

@ -111,13 +111,13 @@
- if @procedure.missing_instructeurs? && @procedure.service.nil?
et
- if @procedure.service.nil?
= link_to("un service", services_path(procedure_id: @procedure))
= link_to("un service", admin_services_path(procedure_id: @procedure))
\.
- else
- if @procedure.missing_steps.include?(:service)
%p.alert.alert-danger
Vous devez renseigner les coordonnées de votre Service administratif avant de pouvoir publier votre démarche.
= link_to 'Cliquez ici.', (@current_administrateur.services.present? ? url_for(services_path(procedure_id: @procedure.id)) : url_for(new_service_path(procedure_id: @procedure.id)))
= link_to 'Cliquez ici.', (@current_administrateur.services.present? ? url_for(admin_services_path(procedure_id: @procedure.id)) : url_for(new_admin_service_path(procedure_id: @procedure.id)))
- if @procedure.missing_steps.include?(:instructeurs)
%p.alert.alert-danger

View file

@ -20,7 +20,7 @@
.procedure-list-element{ class: ('active' if active == 'Description') }
Description
%a#onglet-services{ href: (@procedure.service.present? || current_administrateur.services.present?) ? url_for(services_path(procedure_id: @procedure.id)) : url_for(new_service_path(procedure_id: @procedure.id)) }
%a#onglet-services{ href: (@procedure.service.present? || current_administrateur.services.present?) ? url_for(admin_services_path(procedure_id: @procedure.id)) : url_for(new_admin_service_path(procedure_id: @procedure.id)) }
.procedure-list-element
Service
- if @procedure.missing_steps.include?(:service)

View file

@ -1,4 +1,4 @@
= form_for service, html: { class: 'form' } do |f|
= form_with model: [ :admin, service] , html: { class: 'form' } do |f|
= f.label :nom do
Nom

View file

@ -1,7 +1,7 @@
= render partial: 'new_administrateur/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
link_to('choix du service', services_path(procedure_id: @procedure.id)),
link_to('choix du service', admin_services_path(procedure_id: @procedure.id)),
'modifier le service'] }
.container

View file

@ -24,7 +24,7 @@
%th
nom
%th.change
= link_to('Nouveau service', new_service_path(procedure_id: @procedure.id), class: 'button')
= link_to('Nouveau service', new_admin_service_path(procedure_id: @procedure.id), class: 'button')
%tbody
- @services.each do |service|
@ -32,8 +32,8 @@
%td
= service.nom
%td.change
= link_to('modifier', edit_service_path(service, procedure_id: @procedure.id))
= link_to('modifier', edit_admin_service_path(service, procedure_id: @procedure.id))
= link_to 'supprimer',
service_path(service, procedure_id: @procedure.id),
admin_service_path(service, procedure_id: @procedure.id),
method: :delete,
data: { confirm: "Confirmez vous la suppression de #{service.nom}" }

View file

@ -1,7 +1,7 @@
= render partial: 'new_administrateur/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
link_to('choix du service', services_path(procedure_id: @procedure.id)),
link_to('choix du service', admin_services_path(procedure_id: @procedure.id)),
'nouveau service'] }
.container

View file

@ -406,9 +406,7 @@ Rails.application.routes.draw do
get 'preview', on: :member
end
end
end
scope module: 'new_administrateur' do
resources :services, except: [:show] do
collection do
patch 'add_to_procedure'

View file

@ -33,7 +33,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(Service.last.telephone).to eq('1234') }
it { expect(Service.last.horaires).to eq('horaires') }
it { expect(Service.last.adresse).to eq('adresse') }
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
end
context 'when submitting an invalid service' do
@ -64,7 +64,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(flash.notice).to eq('nom modifié') }
it { expect(Service.last.nom).to eq('nom') }
it { expect(Service.last.type_organisme).to eq(Service.type_organismes.fetch(:association)) }
it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) }
it { expect(response).to redirect_to(admin_services_path(procedure_id: procedure.id)) }
end
context 'when updating a service with invalid data' do
@ -119,7 +119,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
it { expect(flash.alert).to be_nil }
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
end
context 'when a service still has some related procedures' do
@ -133,7 +133,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(service.reload).not_to be_nil }
it { expect(flash.alert).to eq("la démarche #{procedure.libelle} utilise encore le service service. Veuillez l'affecter à un autre service avant de pouvoir le supprimer") }
it { expect(flash.notice).to be_nil }
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
end
end
end