alert admin with service without siret
This commit is contained in:
parent
fa278d5b1a
commit
beaf5751bb
5 changed files with 48 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
module Administrateurs
|
||||
class AdministrateurController < ApplicationController
|
||||
before_action :authenticate_administrateur!
|
||||
before_action :alert_for_missing_siret_service
|
||||
helper_method :administrateur_as_manager?
|
||||
|
||||
def nav_bar_profile
|
||||
|
@ -38,5 +39,24 @@ module Administrateurs
|
|||
current_administrateur.administrateurs_procedures
|
||||
.exists?(procedure_id: id, manager: true)
|
||||
end
|
||||
|
||||
def alert_for_missing_siret_service
|
||||
procedures = missing_siret_services
|
||||
if procedures.any?
|
||||
errors = []
|
||||
errors << I18n.t('shared.procedures.no_siret')
|
||||
procedures.each do |p|
|
||||
errors << I18n.t('shared.procedures.add_siret_to_service_without_siret_html', link: edit_admin_service_path(p.service, procedure_id: p.id), nom: p.service.nom)
|
||||
end
|
||||
flash.now.alert = errors
|
||||
end
|
||||
end
|
||||
|
||||
def missing_siret_services
|
||||
current_administrateur
|
||||
.procedures.publiees
|
||||
.joins(:service)
|
||||
.where(service: { siret: nil })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module Administrateurs
|
||||
class ServicesController < AdministrateurController
|
||||
skip_before_action :alert_for_missing_siret_service, only: :edit
|
||||
def index
|
||||
@services = services.ordered
|
||||
@procedure = procedure
|
||||
|
|
|
@ -822,6 +822,9 @@ en:
|
|||
merger_token_expired: "Le delay to merge your FranceConnect and %{application_name} accounts is expired. Please retry."
|
||||
shared:
|
||||
procedures:
|
||||
no_siret: "Some procedures have service without siret. Please update."
|
||||
add_siret_to_service_without_siret_html: Add siret for service <a href="%{link}">%{nom}</a>
|
||||
|
||||
stats:
|
||||
usual_processing_time: "Usual processing time"
|
||||
processing_time_description: "%{percentile}% of submitted files in the last %{span} days were processed in less than %{days}."
|
||||
|
|
|
@ -876,6 +876,9 @@ fr:
|
|||
merger_token_expired: "Le délai pour fusionner les comptes FranceConnect et %{application_name} est expirée. Veuillez recommencer la procédure pour vous fusionner les comptes."
|
||||
shared:
|
||||
procedures:
|
||||
no_siret: "Vous n'avez pas renseigné le siret du service pour certaines de vos demarches. Merci de les modifier."
|
||||
add_siret_to_service_without_siret_html: Ajouter le siret du service <a href="%{link}">%{nom}</a>
|
||||
|
||||
stats:
|
||||
usual_processing_time: "Temps de traitement usuel"
|
||||
processing_time_description: "%{percentile}% des demandes des %{span} derniers jours ont été traitées en moins de %{days}."
|
||||
|
|
|
@ -157,4 +157,25 @@ describe Administrateurs::ServicesController, type: :controller do
|
|||
it { expect(procedure.reload.service_id).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
let(:admin) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
sign_in(admin.user)
|
||||
end
|
||||
|
||||
context 'when admin has service without siret' do
|
||||
let(:service) { create(:service) }
|
||||
let(:procedure) { create(:procedure, :published, service: service, administrateur: admin) }
|
||||
|
||||
it 'display alert when admin has service without siret' do
|
||||
service.siret = nil
|
||||
service.save(validate: false)
|
||||
get :index, params: { procedure_id: procedure.id }
|
||||
expect(flash.alert.first).to eq "Vous n'avez pas renseigné le siret du service pour certaines de vos demarches. Merci de les modifier."
|
||||
expect(flash.alert.last).to include(service.nom)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue