feat(file retrieval): post targeted email
This commit is contained in:
parent
d86bebdd03
commit
cd7fd5832c
3 changed files with 42 additions and 0 deletions
|
@ -14,9 +14,14 @@ class RecoveriesController < ApplicationController
|
|||
end
|
||||
|
||||
def identification
|
||||
@structure_name = structure_name
|
||||
end
|
||||
|
||||
def post_identification
|
||||
# cookies are used to avoid leaking
|
||||
# email in url
|
||||
cookies[:recover_previous_email] = previous_email
|
||||
|
||||
redirect_to selection_recovery_path
|
||||
end
|
||||
|
||||
|
@ -39,6 +44,12 @@ class RecoveriesController < ApplicationController
|
|||
def siret = current_instructeur.agent_connect_information.siret
|
||||
def previous_email = params[:previous_email]
|
||||
|
||||
def structure_name
|
||||
# we know that the structure exists because
|
||||
# of the ensure_collectivite_territoriale guard
|
||||
APIRechercheEntreprisesService.new.(siret:).value![:nom_complet]
|
||||
end
|
||||
|
||||
def ensure_agent_connect_is_used
|
||||
if current_instructeur&.agent_connect_information.nil?
|
||||
redirect_to support_recovery_path(error: :must_use_agent_connect)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
%h2 Identification du propriétaire des dossiers
|
||||
|
||||
%p Votre organisation est « #{@structure_name} » identifiée par le SIRET #{current_instructeur.agent_connect_information.siret}
|
||||
= form_with do |f|
|
||||
.fr-input-group
|
||||
%label.fr-label{ for: "email" }
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe RecoveriesController, type: :controller do
|
||||
include Dry::Monads[:result]
|
||||
|
||||
describe 'GET #nature' do
|
||||
subject { get :nature }
|
||||
|
||||
|
@ -75,4 +77,32 @@ describe RecoveriesController, type: :controller do
|
|||
it { is_expected.to redirect_to(support_recovery_path(error: 'not_collectivite_territoriale')) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the current instructeur used agent connect and works for a collectivite territoriale' do
|
||||
let(:instructeur) { create(:instructeur, :with_agent_connect_information) }
|
||||
let(:api_recherche_result) do
|
||||
{ nom_complet: 'name', complements: { collectivite_territoriale: { is: :present } } }
|
||||
end
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:current_instructeur).and_return(instructeur)
|
||||
allow_any_instance_of(APIRechercheEntreprisesService).to receive(:call)
|
||||
.and_return(Success(api_recherche_result))
|
||||
end
|
||||
|
||||
describe 'GET #identification' do
|
||||
subject { get :identification }
|
||||
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
end
|
||||
|
||||
describe 'POST #post_identification' do
|
||||
subject { post :post_identification, params: { previous_email: 'email@a.com' } }
|
||||
|
||||
it do
|
||||
is_expected.to redirect_to(selection_recovery_path)
|
||||
expect(cookies[:recover_previous_email]).to eq('email@a.com')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue