-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from etalab/hack/default-request-change-message
Introduce default reason for request changes instruction
- Loading branch information
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/interactors/affect_default_reason_to_instruction_modification_request.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class AffectDefaultReasonToInstructionModificationRequest < ApplicationInteractor | ||
def call | ||
return unless authorization_definition_default_reason | ||
|
||
context.instructor_modification_request.reason ||= authorization_definition_default_reason | ||
end | ||
|
||
private | ||
|
||
def authorization_definition_default_reason | ||
return unless File.exist?(authorization_definition_default_reason_file_path) | ||
|
||
File.read(authorization_definition_default_reason_file_path) | ||
end | ||
|
||
def authorization_definition_default_reason_file_path | ||
Rails.root.join('config', 'instruction_default_modification_request_texts', "#{authorization_request.kind}.text") | ||
end | ||
|
||
def authorization_request | ||
context.instructor_modification_request.authorization_request | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
config/instruction_default_modification_request_texts/hubee_cert_dc.text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Vous avez indiqué le Maire comme étant l’ « Administrateur métier ». | ||
|
||
Sachez que l’administrateur métier est la personne qui bénéficiera des rôles de « Gestion des comptes utilisateurs » des agents instructeurs et de « Gestion des abonnements » aux démarches de votre commune. | ||
De ce fait, cette personne doit être impliquée dans l’utilisation fonctionnelle et quotidienne des demandes des usagers. | ||
|
||
M. le Maire n’étant pas la personne au plus près du traitement quotidien des demandes des usagers, il n'est donc pas nécessaire de l'indiquer en tant qu’Administrateur métier. | ||
|
||
Merci d’indiquer une personne faisant partie de votre service État Civil (vous-même si c’est le cas) et de soumettre à nouveau votre demande. |
8 changes: 8 additions & 0 deletions
8
config/instruction_default_modification_request_texts/hubee_dila.text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Vous avez indiqué le Maire comme étant l’ « Administrateur métier ». | ||
|
||
Sachez que l’administrateur métier est la personne qui bénéficiera des rôles de « Gestion des comptes utilisateurs » des agents instructeurs et de « Gestion des abonnements » aux démarches de votre commune. | ||
De ce fait, cette personne doit être impliquée dans l’utilisation fonctionnelle et quotidienne des demandes des usagers. | ||
|
||
M. le Maire n’étant pas la personne au plus près du traitement quotidien des demandes des usagers, il n'est donc pas nécessaire de l'indiquer en tant qu’Administrateur métier. | ||
|
||
Merci d’indiquer une personne faisant partie de votre service État Civil (vous-même si c’est le cas) et de soumettre à nouveau votre demande. |
21 changes: 21 additions & 0 deletions
21
spec/interactors/affect_default_reason_to_instruction_modification_request_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
RSpec.describe AffectDefaultReasonToInstructionModificationRequest, type: :interactor do | ||
subject(:instructor_modification_request_reason) { described_class.call(instructor_modification_request:).instructor_modification_request.reason } | ||
|
||
let(:instructor_modification_request) { authorization_request.modification_requests.build } | ||
|
||
describe 'with an authorization request kind with a custom default reason' do | ||
let(:authorization_request) { create(:authorization_request, :hubee_cert_dc) } | ||
|
||
it 'affects it' do | ||
expect(instructor_modification_request_reason).to include('Maire') | ||
end | ||
end | ||
|
||
describe 'without an authorization request kind with a custom default reason' do | ||
let(:authorization_request) { create(:authorization_request, :api_entreprise) } | ||
|
||
it 'does not affect any default reason' do | ||
expect(instructor_modification_request_reason).to be_blank | ||
end | ||
end | ||
end |