commit
05df46715a
9 changed files with 73 additions and 10 deletions
|
@ -1,8 +1,10 @@
|
|||
module NewUser
|
||||
class DossiersController < UserController
|
||||
include DossierHelper
|
||||
|
||||
helper_method :new_demarche_url
|
||||
|
||||
before_action :ensure_ownership!, except: [:index, :modifier, :update]
|
||||
before_action :ensure_ownership!, except: [:index, :modifier, :update, :recherche]
|
||||
before_action :ensure_ownership_or_invitation!, only: [:modifier, :update]
|
||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
||||
before_action :forbid_invite_submission!, only: [:update]
|
||||
|
@ -114,6 +116,18 @@ module NewUser
|
|||
end
|
||||
end
|
||||
|
||||
def recherche
|
||||
@dossier_id = params[:dossier_id]
|
||||
dossier = current_user.dossiers.find_by(id: @dossier_id)
|
||||
|
||||
if dossier
|
||||
redirect_to url_for_dossier(dossier)
|
||||
else
|
||||
flash.alert = "Vous n’avez pas de dossier avec le nº #{@dossier_id}."
|
||||
redirect_to dossiers_path
|
||||
end
|
||||
end
|
||||
|
||||
def new_demarche_url
|
||||
"https://doc.demarches-simplifiees.fr/listes-des-demarches"
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class NewAttestationMailer < ApplicationMailer
|
|||
|
||||
Suite à cette opération, l'attestation liée à votre dossier n'a pas été regénérée.
|
||||
Ce problème est désormais reglé, votre nouvelle attestation est disponible à l'adresse suivante :
|
||||
#{dossier_attestation_url(dossier)}
|
||||
#{attestation_dossier_url(dossier)}
|
||||
|
||||
Cordialement,
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class ResendAttestationMailer < ApplicationMailer
|
|||
L'attestation de votre dossier nº #{dossier.id} (procédure "#{dossier.procedure.libelle}") a été modifiée.
|
||||
|
||||
Votre nouvelle attestation est disponible à l'adresse suivante :
|
||||
#{dossier_attestation_url(dossier)}
|
||||
#{attestation_dossier_url(dossier)}
|
||||
|
||||
Cordialement,
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ module TagsSubstitutionConcern
|
|||
{
|
||||
libelle: 'lien attestation',
|
||||
description: '',
|
||||
lambda: -> (d) { external_link(dossier_attestation_url(d)) },
|
||||
lambda: -> (d) { external_link(attestation_dossier_url(d)) },
|
||||
available_for_states: ['accepte']
|
||||
}
|
||||
]
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
%p.title= dossier.attestation.title
|
||||
%p.delivery Délivrée le #{l(dossier.attestation.created_at, format: '%d %B %Y')}
|
||||
- if user_signed_in? && current_user == dossier.user
|
||||
= link_to 'Télécharger', dossier_attestation_path(dossier), target: '_blank', class: 'btn btn-primary'
|
||||
= link_to 'Télécharger', attestation_dossier_path(dossier), target: '_blank', class: 'btn btn-primary'
|
||||
- else
|
||||
= link_to 'Télécharger', attestation_gestionnaire_dossier_path(dossier.procedure, dossier), target: '_blank', class: 'btn btn-primary'
|
||||
|
|
|
@ -47,6 +47,14 @@
|
|||
%button{ title: "Rechercher" }
|
||||
= image_tag "icons/search-blue.svg"
|
||||
|
||||
- if nav_bar_profile == :user && user_signed_in? && current_user.dossiers.count > 2
|
||||
%li
|
||||
.header-search
|
||||
= form_tag recherche_dossiers_path, method: :post, class: "form" do
|
||||
= text_field_tag :dossier_id, "", placeholder: "Numéro de dossier"
|
||||
%button{ title: "Rechercher" }
|
||||
= image_tag "icons/search-blue.svg"
|
||||
|
||||
- if gestionnaire_signed_in? || user_signed_in?
|
||||
%li
|
||||
.header-menu-opener
|
||||
|
|
|
@ -245,12 +245,16 @@ Rails.application.routes.draw do
|
|||
get 'modifier'
|
||||
get 'merci'
|
||||
post 'ask_deletion'
|
||||
end
|
||||
get 'attestation'
|
||||
end
|
||||
|
||||
collection do
|
||||
post 'recherche'
|
||||
# FIXME: to remove when show is implemeted
|
||||
# needed to fix refresh after dossier draft save
|
||||
get 'dossiers/:id', to: redirect('/dossiers/%{id}/modifier')
|
||||
get ':id', to: redirect('/dossiers/%{id}/modifier')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scope module: 'new_gestionnaire', as: 'gestionnaire' do
|
||||
|
|
|
@ -111,7 +111,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
controller.head :ok
|
||||
end
|
||||
|
||||
get :attestation, params: { dossier_id: dossier.id }
|
||||
get :attestation, params: { id: dossier.id }
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,4 +65,41 @@ describe 'user access to the list of his dossier' do
|
|||
expect(page).to have_content(CONTACT_EMAIL)
|
||||
end
|
||||
end
|
||||
|
||||
describe "recherche" do
|
||||
context "when the dossier does not exist" do
|
||||
before do
|
||||
page.find_by_id('dossier_id').set(10000000)
|
||||
click_button("Rechercher")
|
||||
end
|
||||
|
||||
it "shows an error message on the dossiers page" do
|
||||
expect(current_path).to eq(dossiers_path)
|
||||
expect(page).to have_content("Vous n’avez pas de dossier avec le nº 10000000.")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the dossier does not belong to the user" do
|
||||
before do
|
||||
page.find_by_id('dossier_id').set(dossier2.id)
|
||||
click_button("Rechercher")
|
||||
end
|
||||
|
||||
it "shows an error message on the dossiers page" do
|
||||
expect(current_path).to eq(dossiers_path)
|
||||
expect(page).to have_content("Vous n’avez pas de dossier avec le nº #{dossier2.id}.")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the dossier belongs to the user" do
|
||||
before do
|
||||
page.find_by_id('dossier_id').set(dossier1.id)
|
||||
click_button("Rechercher")
|
||||
end
|
||||
|
||||
it "redirects to the dossier page" do
|
||||
expect(current_path).to eq(users_dossier_recapitulatif_path(dossier1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue