views: fix missing attestation link
- Fix the missing link to see attestations (see #4400) - Fix the "Repasser en instruction" wording being confusing for accepted state - Add lot of tests
This commit is contained in:
parent
e3d61a8303
commit
07f75ff20e
2 changed files with 142 additions and 10 deletions
|
@ -1,4 +1,9 @@
|
|||
- if dossier.en_construction? || dossier.en_instruction? || dossier.accepte?
|
||||
- if dossier.en_construction? || dossier.en_instruction?
|
||||
|
||||
-# -----------------------------------------
|
||||
-# Dossier EN CONSTRUCTION ou EN INSTRUCTION
|
||||
-# -----------------------------------------
|
||||
|
||||
%span.dropdown
|
||||
%button.button.primary.dropdown-button
|
||||
= dossier_display_state dossier
|
||||
|
@ -17,13 +22,6 @@
|
|||
%h4 Passer en instruction
|
||||
L'usager ne pourra plus modifier le formulaire
|
||||
|
||||
- if dossier.accepte?
|
||||
%li
|
||||
= link_to repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote: true, confirm: "Confirmez-vous le passage en instruction de ce dossier ?" } do
|
||||
%span.icon.in-progress
|
||||
.dropdown-description
|
||||
%h4 Passer en instruction
|
||||
L'usager ne pourra plus modifier le formulaire
|
||||
- if dossier.en_instruction?
|
||||
%li
|
||||
= link_to repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Confirmez-vous le passage en construction de ce dossier ?" } do
|
||||
|
@ -59,6 +57,11 @@
|
|||
= render partial: 'instructeurs/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Refuser le dossier', placeholder: 'Expliquez au demandeur pourquoi ce dossier est refusé (obligatoire)', popup_class: 'refuse', process_action: 'refuser', title: 'Refuser', confirm: 'Confirmez-vous le refus de ce dossier ?' }
|
||||
|
||||
- else
|
||||
|
||||
-# ---------------------------------------------------
|
||||
-# Dossier TERMINÉ
|
||||
-# ---------------------------------------------------
|
||||
|
||||
- if dossier.motivation.present? || dossier.attestation.present?
|
||||
%span.dropdown
|
||||
%button.button.dropdown-button{ class: button_or_label_class(dossier) }
|
||||
|
@ -74,8 +77,7 @@
|
|||
%p.attestation L'acceptation du dossier a envoyé automatiquement une attestation au demandeur
|
||||
= link_to "Voir l'attestation", attestation_instructeur_dossier_path(dossier.procedure, dossier), target: '_blank', rel: 'noopener', class: 'button'
|
||||
|
||||
|
||||
- if dossier.refuse? || dossier.sans_suite?
|
||||
- if dossier.termine?
|
||||
%ul.dropdown-items.with-top-border
|
||||
%li
|
||||
= link_to repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Voulez vous remettre le dossier #{dossier.id} en instruction ?" } do
|
||||
|
@ -83,6 +85,9 @@
|
|||
.dropdown-description
|
||||
%h4 Repasser en instruction
|
||||
L’usager sera notifié que son dossier est réexaminé.
|
||||
|
||||
- else
|
||||
-# No actions to perform: only display a label with the dossier state
|
||||
-# FIXME: we still should be able to move back the dossier to instruction
|
||||
%span.label{ class: button_or_label_class(dossier) }
|
||||
= dossier_display_state(dossier, lower: true)
|
||||
|
|
127
spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb
Normal file
127
spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb
Normal file
|
@ -0,0 +1,127 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'instructeurs/dossiers/state_button.html.haml', type: :view do
|
||||
include DossierHelper
|
||||
|
||||
subject! do
|
||||
render('instructeurs/dossiers/state_button.html.haml', dossier: dossier)
|
||||
end
|
||||
|
||||
matcher :have_state_label do |expected_title|
|
||||
match do |rendered|
|
||||
expect(rendered).to have_selector('.label', text: expected_title)
|
||||
expect(rendered).not_to have_selector('.dropdown')
|
||||
end
|
||||
end
|
||||
|
||||
matcher :have_dropdown_title do |expected_title|
|
||||
match do |rendered|
|
||||
expect(rendered).to have_selector('.dropdown .dropdown-button', text: expected_title)
|
||||
end
|
||||
end
|
||||
|
||||
matcher :have_dropdown_items do |options|
|
||||
match do |rendered|
|
||||
expected_count = options[:count] || 1
|
||||
expect(rendered).to have_selector('ul.dropdown-items li', count: expected_count)
|
||||
end
|
||||
end
|
||||
|
||||
matcher :have_dropdown_item do |expected_title, options = {}|
|
||||
match do |rendered|
|
||||
expected_href = options[:href]
|
||||
if (expected_href.present?)
|
||||
expect(rendered).to have_selector("ul.dropdown-items li a[href='#{expected_href}']", text: expected_title)
|
||||
else
|
||||
expect(rendered).to have_selector('ul.dropdown-items li', text: expected_title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'brouillon' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
# Currently the state button is not supposed to be displayed for brouillons.
|
||||
# But better have a sane fallback than crashing.
|
||||
|
||||
it 'renders a label' do
|
||||
expect(rendered).to have_state_label('brouillon')
|
||||
end
|
||||
end
|
||||
|
||||
context 'en_contruction' do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
|
||||
it 'renders a dropdown' do
|
||||
expect(rendered).to have_dropdown_title('En construction')
|
||||
expect(rendered).to have_dropdown_items(count: 2)
|
||||
expect(rendered).to have_dropdown_item('En construction')
|
||||
expect(rendered).to have_dropdown_item('Passer en instruction', href: passer_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
end
|
||||
end
|
||||
|
||||
context 'en_instruction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction) }
|
||||
|
||||
it 'renders a dropdown' do
|
||||
expect(rendered).to have_dropdown_title('En instruction')
|
||||
expect(rendered).to have_dropdown_items(count: 5)
|
||||
expect(rendered).to have_dropdown_item('Repasser en construction', href: repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
expect(rendered).to have_dropdown_item('En instruction')
|
||||
expect(rendered).to have_dropdown_item('Accepter')
|
||||
expect(rendered).to have_dropdown_item('Classer sans suite')
|
||||
expect(rendered).to have_dropdown_item('Refuser')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'a dropdown for a closed state' do |state|
|
||||
let(:dossier) { create :dossier, state }
|
||||
|
||||
# FIXME: it should also render the link to move back to instruction
|
||||
it 'renders a simple label' do
|
||||
expect(rendered).to have_state_label(dossier_display_state(dossier, lower: true))
|
||||
end
|
||||
|
||||
context 'with a motivation' do
|
||||
let(:dossier) { create :dossier, state, motivation: 'Correspond au programme' }
|
||||
|
||||
it 'renders a dropdown' do
|
||||
expect(rendered).to have_dropdown_title(dossier_display_state(dossier, lower: true))
|
||||
expect(rendered).to have_dropdown_items(count: 1)
|
||||
expect(rendered).to have_dropdown_item('Repasser en instruction', href: repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
end
|
||||
|
||||
it 'displays the motivation text' do
|
||||
expect(rendered).to have_content('Motivation')
|
||||
expect(rendered).to have_content(dossier.motivation)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an attestation' do
|
||||
let(:dossier) { create :dossier, state, :with_attestation }
|
||||
|
||||
it 'renders a dropdown' do
|
||||
expect(rendered).to have_dropdown_title(dossier_display_state(dossier, lower: true))
|
||||
expect(rendered).to have_dropdown_items(count: 1)
|
||||
expect(rendered).to have_dropdown_item('Repasser en instruction', href: repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
end
|
||||
|
||||
it 'provides a link to the attestation' do
|
||||
expect(rendered).to have_content('Attestation')
|
||||
expect(rendered).to have_link(href: attestation_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'accepte' do
|
||||
it_behaves_like 'a dropdown for a closed state', :accepte
|
||||
end
|
||||
|
||||
context 'refuse' do
|
||||
it_behaves_like 'a dropdown for a closed state', :refuse
|
||||
end
|
||||
|
||||
context 'sans_suite' do
|
||||
it_behaves_like 'a dropdown for a closed state', :sans_suite
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue