diff --git a/app/facades/new_authorization_request/base.rb b/app/facades/new_authorization_request/base.rb index 01964f630..023a15339 100644 --- a/app/facades/new_authorization_request/base.rb +++ b/app/facades/new_authorization_request/base.rb @@ -39,6 +39,10 @@ def public_available_forms AuthorizationRequestFormDecorator.decorate_collection(authorization_definition.public_available_forms) end + def public_available_forms_sandbox + AuthorizationRequestFormDecorator.decorate_collection(authorization_definition.public_available_forms_sandbox) + end + private def sorted_editors diff --git a/app/models/authorization_definition.rb b/app/models/authorization_definition.rb index d759b83bd..4d3c97161 100644 --- a/app/models/authorization_definition.rb +++ b/app/models/authorization_definition.rb @@ -72,12 +72,25 @@ def public_available_forms end end + def public_available_forms_sandbox + available_forms_sandbox.select do |form| + form.public && + form.startable_by_applicant + end + end + def available_forms AuthorizationRequestForm.where(authorization_request_class:).sort do |form| form.default ? 1 : 0 end end + def available_forms_sandbox + AuthorizationRequestForm.where(authorization_request_class: authorization_request_class_sandbox).sort do |form| + form.default ? 1 : 0 + end + end + def public value_or_default(@public, true) end @@ -91,4 +104,8 @@ def startable_by_applicant def authorization_request_class @authorization_request_class ||= AuthorizationRequest.const_get(id.classify) end + + def authorization_request_class_sandbox + @authorization_request_class_sandbox ||= AuthorizationRequest.const_get("#{id}_sandbox".classify) + end end diff --git a/app/views/authorization_requests/new/api_impot_particulier.html.erb b/app/views/authorization_requests/new/api_impot_particulier.html.erb index 884cfbd4b..fa9cebcf3 100644 --- a/app/views/authorization_requests/new/api_impot_particulier.html.erb +++ b/app/views/authorization_requests/new/api_impot_particulier.html.erb @@ -98,7 +98,6 @@ id="forms" class="fr-background-alt--blue-france fr-py-4w fr-hidden" > - <%# TODO: Adapt facade to sandbox %>
@@ -111,7 +110,7 @@
diff --git a/config/locales/authorization_request_forms.fr.yml b/config/locales/authorization_request_forms.fr.yml index a6c083210..bd0f5837d 100644 --- a/config/locales/authorization_request_forms.fr.yml +++ b/config/locales/authorization_request_forms.fr.yml @@ -723,7 +723,7 @@ fr: Si vous n’avez pas encore contacté la DGFiP, vous pouvez les joindre à l’adresse dtnum.donnees.demande-acces@dgfip.finances.gouv.fr - api_impot_particulier_production_avec_editeur: *api_impot_particulier_sandbox + api_impot_particulier_production_editeur: *api_impot_particulier_sandbox formulaire_qf: legal: *api_particulier_editor_common_wordings diff --git a/docs/ajout_nouveau_bloc_de_formulaire.md b/docs/ajout_nouveau_bloc_de_formulaire.md index bc142106d..5cd3bd971 100644 --- a/docs/ajout_nouveau_bloc_de_formulaire.md +++ b/docs/ajout_nouveau_bloc_de_formulaire.md @@ -29,7 +29,7 @@ On va faire référence au premier exemple dans la suite de cette documentation. Il faut mettre à jour la factory du formulaire pour que ses tests restent valides : - Ajouter la factory `with_safety_certification` dans `spec/factories/authorization_requests.rb` -- L'inclure dans la factory du form qui l'utilise (ici c'est `api_impot_particulier_production_avec_editeur`) +- L'inclure dans la factory du form qui l'utilise (ici c'est `api_impot_particulier_production_editeur`) Il reste plus qu'à ajouter le test e2e, que l'on peut voir pour notre exemple dans [ce commit](https://github.com/etalab/data_pass/commit/fe4c8e9e4770a001d6d71f0cf6861f6fc9e6dd90) : - Faire la step `Quand("Je renseigne l'homologation de sécurité")` diff --git a/spec/models/authorization_definition_spec.rb b/spec/models/authorization_definition_spec.rb index 3f0abc908..22cd3930b 100644 --- a/spec/models/authorization_definition_spec.rb +++ b/spec/models/authorization_definition_spec.rb @@ -8,14 +8,29 @@ describe '.available_forms' do subject(:available_forms) { instance.available_forms } - let(:instance) { described_class.find('api_entreprise') } + let(:instance) { described_class.find('api_impot_particulier') } it 'returns a list of all forms' do expect(available_forms.count).to be > 0 expect(available_forms).to be_all do |form| form.is_a?(AuthorizationRequestForm) && - form.authorization_request_class == AuthorizationRequest::APIEntreprise + form.authorization_request_class == AuthorizationRequest::APIImpotParticulier + end + end + end + + describe '.available_forms_sandbox' do + subject(:available_forms_sandbox) { instance.available_forms_sandbox } + + let(:instance) { described_class.find('api_impot_particulier') } + + it 'returns a list of all sandbox forms' do + expect(available_forms_sandbox.count).to be > 0 + + expect(available_forms_sandbox).to be_all do |form| + form.is_a?(AuthorizationRequestForm) && + form.authorization_request_class == AuthorizationRequest::APIImpotParticulierSandbox end end end