Merge pull request #7927 from colinux/fix-invitation-on-hidden-dossier
fix(invitation): when dossier is not visible anymore
This commit is contained in:
commit
a5af9721d2
4 changed files with 17 additions and 2 deletions
|
@ -35,6 +35,9 @@ class TargetedUserLink < ApplicationRecord
|
||||||
case target_context
|
case target_context
|
||||||
when "invite"
|
when "invite"
|
||||||
invite = target_model
|
invite = target_model
|
||||||
|
|
||||||
|
fail ActiveRecord::RecordNotFound if invite.nil?
|
||||||
|
|
||||||
user = User.find_by(email: target_email)
|
user = User.find_by(email: target_email)
|
||||||
user&.active? ?
|
user&.active? ?
|
||||||
url_helper.invite_path(invite) :
|
url_helper.invite_path(invite) :
|
||||||
|
|
|
@ -362,7 +362,7 @@ en:
|
||||||
messages:
|
messages:
|
||||||
dossier_not_found: "The file does not exist or you do not have access to it."
|
dossier_not_found: "The file does not exist or you do not have access to it."
|
||||||
# # dossier_map_not_activated: "The file does not have access to the map."
|
# # dossier_map_not_activated: "The file does not have access to the map."
|
||||||
targeted_user_link_expired: "This invitation link is not more accessible."
|
targeted_user_link_expired: "This invitation link or the file is no longer available."
|
||||||
invalid_siret: "The SIRET is incorrect"
|
invalid_siret: "The SIRET is incorrect"
|
||||||
procedure_not_found: "The procedure does not exist"
|
procedure_not_found: "The procedure does not exist"
|
||||||
siret_unknown: 'Sorry, we did not find any establishment registered under this SIRET number.'
|
siret_unknown: 'Sorry, we did not find any establishment registered under this SIRET number.'
|
||||||
|
|
|
@ -367,7 +367,7 @@ fr:
|
||||||
saml_not_authorized: "Vous n’êtes pas autorisé à accéder à ce service."
|
saml_not_authorized: "Vous n’êtes pas autorisé à accéder à ce service."
|
||||||
dossier_not_found: "Le dossier n’existe pas ou vous n’y avez pas accès."
|
dossier_not_found: "Le dossier n’existe pas ou vous n’y avez pas accès."
|
||||||
# dossier_map_not_activated: "Le dossier n’a pas accès à la cartographie."
|
# dossier_map_not_activated: "Le dossier n’a pas accès à la cartographie."
|
||||||
targeted_user_link_expired: "Ce lien d'invitation n'est plus valable."
|
targeted_user_link_expired: "Ce lien d'invitation n'est plus valable ou le dossier n'est plus accessible."
|
||||||
invalid_siret: "Le siret est incorrect"
|
invalid_siret: "Le siret est incorrect"
|
||||||
procedure_not_found: "La démarche n’existe pas"
|
procedure_not_found: "La démarche n’existe pas"
|
||||||
siret_unknown: 'Désolé, nous n’avons pas trouvé d’établissement enregistré correspondant à ce numéro SIRET.'
|
siret_unknown: 'Désolé, nous n’avons pas trouvé d’établissement enregistré correspondant à ce numéro SIRET.'
|
||||||
|
|
|
@ -92,6 +92,17 @@ describe TargetedUserLinksController, type: :controller do
|
||||||
expect(response).to redirect_to(invite_path(target_model, email: target_model.email))
|
expect(response).to redirect_to(invite_path(target_model, email: target_model.email))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when there is no dossier visible anymore' do
|
||||||
|
let(:user) { nil }
|
||||||
|
let(:target_model) { create(:invite, user: user, dossier: create(:dossier, hidden_by_user_at: 1.day.ago)) }
|
||||||
|
|
||||||
|
it 'redirect nicely' do
|
||||||
|
get :show, params: { id: targeted_user_link.id }
|
||||||
|
expect(response).to redirect_to(root_path)
|
||||||
|
expect(flash[:error]).to match(/dossier n'est plus accessible/)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invite not having user' do
|
context 'with invite not having user' do
|
||||||
|
@ -139,6 +150,7 @@ describe TargetedUserLinksController, type: :controller do
|
||||||
get :show, params: { id: "asldjiasld" }
|
get :show, params: { id: "asldjiasld" }
|
||||||
expect(response).to redirect_to(root_path)
|
expect(response).to redirect_to(root_path)
|
||||||
expect(flash[:error]).to be_present
|
expect(flash[:error]).to be_present
|
||||||
|
expect(flash[:error]).to match(/invitation n'est plus valable/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue