dossiers: generate the correct link to see the dossier details
This commit is contained in:
parent
07f3effb02
commit
148dc164f7
4 changed files with 44 additions and 9 deletions
|
@ -15,6 +15,16 @@ module DossierHelper
|
|||
end
|
||||
end
|
||||
|
||||
def url_for_dossier(dossier)
|
||||
if dossier.kind_of? Invite
|
||||
users_dossiers_invite_path(id: dossier.id)
|
||||
elsif dossier.brouillon?
|
||||
modifier_dossier_path(dossier)
|
||||
else
|
||||
users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
end
|
||||
|
||||
def dossier_submission_is_closed?(dossier)
|
||||
dossier.brouillon? && dossier.procedure.archivee?
|
||||
end
|
||||
|
|
|
@ -37,19 +37,19 @@
|
|||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%td.folder-col
|
||||
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
%td.number-col
|
||||
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.id
|
||||
%td
|
||||
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.procedure.libelle
|
||||
%td.status-col
|
||||
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= render partial: 'shared/dossiers/status', locals: { dossier: dossier }
|
||||
%td.updated-at-col
|
||||
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.updated_at.localtime.strftime("%d/%m/%Y")
|
||||
= paginate(@dossiers)
|
||||
|
||||
|
|
|
@ -26,6 +26,25 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
end
|
||||
end
|
||||
|
||||
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" }
|
||||
end
|
||||
|
||||
context "when the dossier is any other state" do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
it { is_expected.to eq "/users/dossiers/#{dossier.id}/recapitulatif" }
|
||||
end
|
||||
end
|
||||
|
||||
describe ".dossier_submission_is_closed?" do
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
let(:state) { "brouillon" }
|
||||
|
|
|
@ -2,7 +2,9 @@ require 'spec_helper'
|
|||
|
||||
describe 'new_user/dossiers/index.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
let(:user_dossiers) { create_list(:dossier, 2, state: 'brouillon', user: user) }
|
||||
let(:dossier_brouillon) { create(:dossier, state: 'brouillon', user: user) }
|
||||
let(:dossier_en_construction) { create(:dossier, state: 'en_construction', user: user) }
|
||||
let(:user_dossiers) { [dossier_brouillon, dossier_en_construction] }
|
||||
let(:dossiers_invites) { [] }
|
||||
let(:current_tab) { 'mes-dossiers' }
|
||||
|
||||
|
@ -21,9 +23,13 @@ describe 'new_user/dossiers/index.html.haml', type: :view do
|
|||
|
||||
it 'affiche les informations des dossiers' do
|
||||
dossier = user_dossiers.first
|
||||
expect(rendered).to have_text(dossier.id)
|
||||
expect(rendered).to have_text(dossier.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier.id, href: users_dossier_recapitulatif_path(dossier))
|
||||
expect(rendered).to have_text(dossier_brouillon.id)
|
||||
expect(rendered).to have_text(dossier_brouillon.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_brouillon.id, href: modifier_dossier_path(dossier_brouillon))
|
||||
|
||||
expect(rendered).to have_text(dossier_en_construction.id)
|
||||
expect(rendered).to have_text(dossier_en_construction.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_en_construction.id, href: users_dossier_recapitulatif_path(dossier_en_construction))
|
||||
end
|
||||
|
||||
context 'quand il n’y a aucun dossier' do
|
||||
|
|
Loading…
Reference in a new issue