diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index df860054b..971c471dd 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -7,6 +7,20 @@ module NewUser before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :forbid_invite_submission!, only: [:update] + def index + @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) + @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) + + @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) + + @dossiers = case @current_tab + when 'mes-dossiers' + @user_dossiers + when 'dossiers-invites' + @dossiers_invites + end + end + def attestation send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end @@ -87,20 +101,6 @@ module NewUser @dossier = current_user.dossiers.includes(:procedure).find(params[:id]) end - def index - @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) - @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) - - @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) - - @dossiers = case @current_tab - when 'mes-dossiers' - @user_dossiers - when 'dossiers-invites' - @dossiers_invites - end - end - def ask_deletion dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id]) diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index 9baaf6d16..f6769e34c 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -16,9 +16,7 @@ module DossierHelper end def url_for_dossier(dossier) - if dossier.kind_of? Invite - users_dossiers_invite_path(id: dossier.id) - elsif dossier.brouillon? + if dossier.brouillon? modifier_dossier_path(dossier) else users_dossier_recapitulatif_path(dossier) diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index 84576f3e6..f2de5783f 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -56,5 +56,5 @@ - else .dossiers-table-empty %h2.empty-text Aucun dossier. - %p.empty-text-details Pour l’instant vous n’avez commencé aucune démarche. + %p.empty-text-details Vous n’avez pas encore commencé de démarche. = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary" diff --git a/spec/helpers/dossier_helper_spec.rb b/spec/helpers/dossier_helper_spec.rb index c2aa7d0d4..9d12f985a 100644 --- a/spec/helpers/dossier_helper_spec.rb +++ b/spec/helpers/dossier_helper_spec.rb @@ -29,11 +29,6 @@ RSpec.describe DossierHelper, type: :helper do describe ".url_for_dossier" do subject { url_for_dossier(dossier) } - context "when the dossier is an invitation" do - let(:dossier) { create(:invite) } - it { is_expected.to eq "/users/dossiers/invites/#{dossier.id}" } - end - context "when the dossier is in the brouillon state" do let(:dossier) { create(:dossier, state: 'brouillon') } it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }