Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthorizationRequestFormsController not found redirect with an alert #627

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/authorization_request_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class AuthorizationRequestFormsController < AuthenticatedUserController
helper AuthorizationRequestsHelpers
include AuthorizationRequestsFlashes

rescue_from StaticApplicationRecord::EntryNotFound do
redirect_to root_path, alert: t('authorization_request_forms.form_not_found')
end

allow_unauthenticated_access only: [:new]

before_action :extract_authorization_request_form
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ fr:
cta: Débuter ma demande

authorization_request_forms:
form_not_found: Le formulaire demandé n'existe pas
new:
back_to_dashboard: Retour à l’accueil
title: *start_new_habilitation_title
Expand Down
16 changes: 16 additions & 0 deletions spec/controllers/authorization_request_forms_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
RSpec.describe AuthorizationRequestFormsController, type: :controller do
describe 'GET #new' do
subject(:new_authorization_request_form) { get :new, params: { form_uid: } }

context 'with invalid form uid' do
let(:form_uid) { 'invalid' }

it 'redirects to root path with an error message' do
new_authorization_request_form

expect(response).to redirect_to(root_path)
expect(flash[:alert]).to eq("Le formulaire demandé n'existe pas")
end
end
end
end
Loading