Merge pull request #10839 from demarches-simplifiees/fix-10837
ETQ Administrateur, si j'oublie de renseigner le SIRET de mon service, je souhaite recevoir un message d'erreur explicite pour m'alerter.
This commit is contained in:
commit
af0692163b
4 changed files with 14 additions and 4 deletions
|
@ -653,7 +653,7 @@ class Procedure < ApplicationRecord
|
||||||
result << :service
|
result << :service
|
||||||
end
|
end
|
||||||
|
|
||||||
if service_test?
|
if service_siret_test?
|
||||||
result << :service
|
result << :service
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def service_test?
|
def service_siret_test?
|
||||||
service&.siret == Service::SIRET_TEST
|
service&.siret == Service::SIRET_TEST
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Service < ApplicationRecord
|
||||||
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
||||||
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :siret, siret_format: true
|
validates :siret, siret_format: true
|
||||||
|
validates :siret, comparison: { other_than: SIRET_TEST, message: "n'est pas valide" }, on: :update
|
||||||
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :telephone, phone: { possible: true, allow_blank: true }
|
validates :telephone, phone: { possible: true, allow_blank: true }
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
%li= link_to("des instructeurs", admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur))
|
%li= link_to("des instructeurs", admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur))
|
||||||
- if @procedure.service.nil?
|
- if @procedure.service.nil?
|
||||||
%li= link_to("un service", admin_services_path(procedure_id: @procedure))
|
%li= link_to("un service", admin_services_path(procedure_id: @procedure))
|
||||||
- if @procedure.service_test?
|
- if @procedure.service_siret_test?
|
||||||
%li= link_to("un service valide", admin_services_path(procedure_id: @procedure))
|
%li= link_to("un service avec un SIRET valide", admin_services_path(procedure_id: @procedure))
|
||||||
= link_to t('.back_to_procedure'), admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-arrow-go-back-line fr-mt-2w'
|
= link_to t('.back_to_procedure'), admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-arrow-go-back-line fr-mt-2w'
|
||||||
|
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -89,6 +89,15 @@ describe Service, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'validation on update' do
|
||||||
|
subject { create(:service) }
|
||||||
|
|
||||||
|
it 'should not allow to have a test siret' do
|
||||||
|
subject.siret = Service::SIRET_TEST
|
||||||
|
expect(subject).not_to be_valid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "etablissement adresse & geo coordinates" do
|
describe "etablissement adresse & geo coordinates" do
|
||||||
subject { create(:service, etablissement_lat: latitude, etablissement_lng: longitude, etablissement_infos: etablissement_infos) }
|
subject { create(:service, etablissement_lat: latitude, etablissement_lng: longitude, etablissement_infos: etablissement_infos) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue