Skip to content

Commit

Permalink
Impot Particulier disjunction Sandbox/Prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelfaure committed Dec 17, 2024
1 parent c2b5699 commit b0764c7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/facades/new_authorization_request/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions app/models/authorization_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
id="forms"
class="fr-background-alt--blue-france fr-py-4w fr-hidden"
>
<%# TODO: Adapt facade to sandbox %>
<div class="fr-grid-row">
<div class="fr-col-md-10 fr-col-offset-1">
<p class="center fr-px-5w fr-py-1w">
Expand All @@ -111,7 +110,7 @@
</p>

<div class="fr-grid-row fr-grid-row--center">
<% @facade.public_available_forms.each do |authorization_request_form| %>
<% @facade.public_available_forms_sandbox.each do |authorization_request_form| %>
<div
data-choose-authorization-request-form-target="form"
data-choose-authorization-request-form-tags="<%= authorization_request_form.tags.to_json %>"
Expand All @@ -133,7 +132,6 @@
id="forms"
class="fr-background-alt--blue-france fr-py-4w fr-hidden"
>
<%# TODO: Adapt facade to editor %>
<div class="fr-grid-row">
<div class="fr-col-md-10 fr-col-offset-1">
<p class="center fr-px-5w fr-py-1w">
Expand Down
2 changes: 1 addition & 1 deletion config/locales/authorization_request_forms.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ fr:
Si vous n’avez pas encore contacté la DGFiP, vous pouvez les joindre à l’adresse
<a href="mailto:[email protected]" target="_blank">[email protected]</a>
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
Expand Down
2 changes: 1 addition & 1 deletion docs/ajout_nouveau_bloc_de_formulaire.md
Original file line number Diff line number Diff line change
Expand Up @@ -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é")`
Expand Down
19 changes: 17 additions & 2 deletions spec/models/authorization_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b0764c7

Please sign in to comment.