feat(file retrieval): ensure agent connect is used
This commit is contained in:
parent
d3955d48ee
commit
fac365e01d
3 changed files with 37 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
class RecoveriesController < ApplicationController
|
class RecoveriesController < ApplicationController
|
||||||
|
before_action :ensure_agent_connect_is_used, except: [:nature, :post_nature, :support]
|
||||||
|
|
||||||
def nature
|
def nature
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,4 +35,10 @@ class RecoveriesController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def nature_params = params[:nature]
|
def nature_params = params[:nature]
|
||||||
|
|
||||||
|
def ensure_agent_connect_is_used
|
||||||
|
if current_instructeur&.agent_connect_information.nil?
|
||||||
|
redirect_to support_recovery_path(error: :must_use_agent_connect)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,3 +11,14 @@
|
||||||
'Contactez le support',
|
'Contactez le support',
|
||||||
subject: 'Récupération de dossiers',
|
subject: 'Récupération de dossiers',
|
||||||
class: 'fr-btn')
|
class: 'fr-btn')
|
||||||
|
|
||||||
|
- when 'must_use_agent_connect'
|
||||||
|
%p Vous devez utiliser le portail AgentConnect pour récupérer vos dossiers.
|
||||||
|
|
||||||
|
= link_to(agent_connect_login_path, class: "fr-btn fr-connect") do
|
||||||
|
%span.fr-connect__login
|
||||||
|
= t('signin_with', scope: [:agent_connect, :agent, :index])
|
||||||
|
%span.fr-connect__brand AgentConnect
|
||||||
|
|
||||||
|
%p Vous n'avez pas encore de compte AgentConnect ? Vous pouvez en créer un en utilisant MonComptePro.
|
||||||
|
= link_to 'MonComptePro', 'https://moncomptepro.beta.gouv.fr', class: 'fr-btn'
|
||||||
|
|
|
@ -26,4 +26,22 @@ describe RecoveriesController, type: :controller do
|
||||||
|
|
||||||
it { is_expected.to have_http_status(:success) }
|
it { is_expected.to have_http_status(:success) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'ensure_agent_connect_is_used' do
|
||||||
|
subject { post :selection }
|
||||||
|
|
||||||
|
context 'when agent connect is used' do
|
||||||
|
let(:instructeur) { create(:instructeur, :with_agent_connect_information) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(controller).to receive(:current_instructeur).and_return(instructeur)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to have_http_status(:success) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when agent connect is not used' do
|
||||||
|
it { is_expected.to redirect_to(support_recovery_path(error: :must_use_agent_connect)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue