Merge pull request #10877 from mfo/US/add-breadcrumb-to-instructeur-procedure-management

amelioration : ETQ instructeur, je peux naviguer entre l'onglet de ma demarche et mes dossiers sans perdre le context (onglet et page) en utilisant un bouton retour
This commit is contained in:
mfo 2024-11-28 13:55:23 +00:00 committed by GitHub
commit 8ba2c5c5ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 259 additions and 174 deletions

View file

@ -13,4 +13,8 @@ class Dossiers::BatchAlertComponent < ApplicationComponent
@batch.seen_at = Time.zone.now
@batch.save
end
def procedure_path
instructeur_procedure_path(@procedure, statut: params[:statut])
end
end

View file

@ -12,7 +12,7 @@
%p= t(".#{batch.operation}.in_progress.text_success", count: @batch.total_count, success_count: @batch.success_count)
%p
= link_to t('.link_text'), instructeur_procedure_path(@procedure, statut: params["statut"]), data: { action: 'turbo-poll#refresh' }
= link_to t('.link_text'), procedure_path, data: { action: 'turbo-poll#refresh' }
= t('.after_link_text')
%p.fr-mt-2w

View file

@ -80,7 +80,7 @@ class Dossiers::MessageComponent < ApplicationComponent
end
def delete_url
groupe_gestionnaire ? gestionnaire_groupe_gestionnaire_commentaire_path(groupe_gestionnaire, commentaire) : instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire)
groupe_gestionnaire ? gestionnaire_groupe_gestionnaire_commentaire_path(groupe_gestionnaire, commentaire, statut: params[:statut]) : instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire, statut: params[:statut])
end
def highlight?

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class Instructeurs::BackButtonComponent < ApplicationComponent
def initialize(to:)
@to = to
end
def call
link_to "", @to, class: 'back-btn fr-btn fr-btn--secondary fr-btn--sm fr-mr-2w fr-icon-arrow-left-line', title: t('.back')
end
end

View file

@ -0,0 +1,3 @@
en:
back: Back to list of files

View file

@ -0,0 +1,3 @@
fr:
back: Retour à la liste des dossiers

View file

@ -4,7 +4,7 @@
- if dossier.may_repasser_en_construction?
= menu.with_item do
= link_to(repasser_en_construction_instructeur_dossier_path(dossier.procedure.id, dossier.id), method: :post, role: 'menuitem') do
= link_to(repasser_en_construction_instructeur_dossier_path(dossier.procedure.id, dossier.id, statut: params[:statut]), method: :post, role: 'menuitem') do
%span.fr-icon.fr-icon-draft-line.fr-text-default--info.fr-mt-1v{ "aria-hidden": "true" }
.dropdown-description
%h4= t('.revert_en_construction')
@ -27,7 +27,7 @@
- menu.with_item(class: "inactive form-inside fr-pt-1v") do
= render partial: 'instructeurs/dossiers/instruction_button_motivation', locals: { dossier:,
visible: true,
form_path: pending_correction_instructeur_dossier_path(dossier.procedure, dossier),
form_path: pending_correction_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]),
placeholder: 'Expliquez au demandeur quelle(s) correction(s) sont attendues',
popup_class: 'pending_correction',
button_justificatif_label: "Ajouter une pièce jointe (facultatif)",

View file

@ -22,7 +22,7 @@ module Instructeurs
else
flash[:notice] = "Cette archive a déjà été générée."
end
redirect_to instructeur_archives_path(@procedure)
redirect_to list_instructeur_archives_path(@procedure)
end
private

View file

@ -12,7 +12,7 @@ module Instructeurs
avis = Avis.find(params[:id])
if avis.revoke_by!(current_instructeur)
flash.notice = "#{avis.expert.email} ne peut plus donner son avis sur ce dossier."
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, params[:statut], avis.dossier))
end
end
@ -25,7 +25,7 @@ module Instructeurs
AvisMailer.avis_invitation(avis).deliver_later
end
flash.notice = "Un mail de relance a été envoyé à #{avis.expert.email}"
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, params[:statut], avis.dossier))
end
end
end

View file

@ -278,7 +278,7 @@ module Instructeurs
@commentaire.dossier.touch(:last_commentaire_updated_at)
current_instructeur.follow(dossier)
flash.notice = "Message envoyé"
redirect_to messagerie_instructeur_dossier_path(procedure, dossier)
redirect_to messagerie_instructeur_dossier_path(procedure, dossier, statut: statut)
else
@commentaire.piece_jointe.purge.reload
flash.alert = @commentaire.errors.full_messages
@ -290,7 +290,7 @@ module Instructeurs
@avis = create_avis_from_params(dossier, current_instructeur)
if @avis.nil?
redirect_to avis_instructeur_dossier_path(procedure, dossier)
redirect_to avis_instructeur_dossier_path(procedure, dossier, statut: statut)
else
@avis_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.avis_seen_at
render :avis

View file

@ -1,2 +1,2 @@
= render(Dsfr::SidemenuComponent.new) do |component|
- component.with_links([{ name: t('helpers.sidemenu.see_avis'), url: avis_instructeur_dossier_path(@dossier.procedure, @dossier) }, { name: t('helpers.sidemenu.ask_avis'), url: avis_new_instructeur_dossier_path(@dossier.procedure, @dossier) }])
- component.with_links([{ name: t('helpers.sidemenu.see_avis'), url: avis_instructeur_dossier_path(procedure_id: @dossier.procedure.id, statut: params[:statut], dossier_id: @dossier.id) }, { name: t('helpers.sidemenu.ask_avis'), url: avis_new_instructeur_dossier_path(@dossier.procedure, params[:statut], @dossier) }])

View file

@ -4,30 +4,30 @@
- notifications_summary = current_instructeur.notifications_for_dossier(dossier)
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.request'),
instructeur_dossier_path(dossier.procedure, dossier),
instructeur_dossier_path(dossier.procedure, params[:statut], dossier),
notification: notifications_summary[:demande])
- if gallery_attachments.present?
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.attachments'),
pieces_jointes_instructeur_dossier_path(dossier.procedure, dossier),
pieces_jointes_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]),
notification: notifications_summary[:pieces_jointes])
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.private_annotations'),
annotations_privees_instructeur_dossier_path(dossier.procedure, dossier),
annotations_privees_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]),
notification: notifications_summary[:annotations_privees])
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.external_opinion'),
[avis_instructeur_dossier_path(dossier.procedure, dossier),
avis_new_instructeur_dossier_path(dossier.procedure, dossier)],
[avis_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]),
avis_new_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut])],
notification: notifications_summary[:avis])
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.messaging'),
messagerie_instructeur_dossier_path(dossier.procedure, dossier),
messagerie_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]),
notification: notifications_summary[:messagerie])
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.involved_persons'),
personnes_impliquees_instructeur_dossier_path(dossier.procedure, dossier))
personnes_impliquees_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]))
- if dossier.procedure.routing_enabled?
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.reaffectation'),
reaffectation_instructeur_dossier_path(dossier.procedure, dossier))
reaffectation_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]))

View file

@ -1,9 +1,12 @@
#header-top.fr-container
.flex
%div
.flex.fr-mb-1w
= render Instructeurs::BackButtonComponent.new(to: instructeur_procedure_path(dossier.procedure, statut: params[:statut]))
%h1.fr-h3.fr-mb-1w
= t('show_dossier', scope: [:layouts, :breadcrumb], dossier_id: dossier.id, owner_name: dossier.owner_name)
= link_to dossier.procedure.libelle.truncate_words(10), instructeur_procedure_path(dossier.procedure), title: dossier.procedure.libelle, class: "fr-link"
.fr-mt-2w.fr-badge-group
= procedure_badge(dossier.procedure)

View file

@ -1,5 +1,5 @@
.motivation{ class: class_names(popup_class => true, hidden: !defined?(visible) || !visible, "fr-pb-2w fr-px-2w": true) }
= form_tag(defined?(form_path) ? form_path : terminer_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo: true, turbo_confirm: confirm }, method: :post, multipart: true) do
= form_tag(defined?(form_path) ? form_path : terminer_instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut]), data: { turbo: true, turbo_confirm: confirm }, method: :post, multipart: true) do
- if title == 'Accepter'
= text_area :dossier, :motivation, class: 'fr-input', placeholder: placeholder, required: false
- if dossier.attestation_template&.activated?

View file

@ -12,7 +12,7 @@
Uniquement cet onglet
- menu.with_item do
= link_to instructeur_dossier_path(dossier.procedure, dossier, format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link", role: 'menuitem' do
= link_to instructeur_dossier_path(dossier.procedure, dossier, statut: params[:statut], format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link", role: 'menuitem' do
Export PDF
- if dossier.geo_data?

View file

@ -9,7 +9,7 @@
.fr-col
- if !@dossier.termine?
- if @dossier.procedure.allow_expert_review
= render partial: "shared/avis/form", locals: { url: avis_instructeur_dossier_path(@dossier.procedure, @dossier), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: false, avis: @avis }
= render partial: "shared/avis/form", locals: { url: avis_instructeur_dossier_path(@dossier.procedure, params[:statut], @dossier), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: false, avis: @avis }
- else
%h2.empty-text
= t('helpers.information_text.unauthorized_avis_text')

View file

@ -2,4 +2,4 @@
= render partial: "header", locals: { dossier: @dossier, gallery_attachments: @gallery_attachments }
= render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_instructeur, messagerie_seen_at: @messagerie_seen_at , new_commentaire: @commentaire, form_url: commentaire_instructeur_dossier_path(@dossier.procedure, @dossier) }
= render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_instructeur, messagerie_seen_at: @messagerie_seen_at , new_commentaire: @commentaire, form_url: commentaire_instructeur_dossier_path(@dossier.procedure, @dossier, statut: params[:statut]) }

View file

@ -25,23 +25,23 @@
= ""
- else
= button_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-edit-line', form: { data: { turbo: turbo ? 'true' : 'false' } } do
= button_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id, statut: params[:statut]), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-edit-line', form: { data: { turbo: turbo ? 'true' : 'false' } } do
Repasser en instruction
= button_to archive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-icon-folder-2-line' do
= button_to archive_instructeur_dossier_path(procedure_id, dossier_id, statut: params[:statut]), method: :patch, class: 'fr-btn fr-icon-folder-2-line' do
Archiver le dossier
= button_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier') do
= button_to instructeur_dossier_path(procedure_id, dossier_id, statut: params[:statut]), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier') do
= ""
- elsif Dossier::EN_CONSTRUCTION_OU_INSTRUCTION.include?(state)
- if dossier_is_followed
%li
= button_to unfollow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-fill' do
= button_to unfollow_instructeur_dossier_path(procedure_id, statut: params[:statut], dossier_id:), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-fill' do
= t('views.instructeurs.dossiers.stop_follow')
- else
%li
= button_to follow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-line' do
= button_to follow_instructeur_dossier_path(procedure_id, statut: params[:statut], dossier_id:), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-line' do
= t('views.instructeurs.dossiers.follow_file')
- if with_menu
@ -50,7 +50,7 @@
- if Dossier.states[:en_construction] == state
%li{ 'data-turbo': turbo ? 'true' : 'false' }
= button_to passer_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-icon-edit-line',
= button_to passer_en_instruction_instructeur_dossier_path(procedure_id, statut: params[:statut], dossier_id:), method: :post, class: 'fr-btn fr-icon-edit-line',
disabled: has_blocking_pending_correction, "aria-describedby" => has_blocking_pending_correction ? "tooltip-passer-en-instruction" : nil do
= t('views.instructeurs.dossiers.passer_en_instruction')
@ -60,5 +60,5 @@
- elsif Dossier.states[:en_instruction] == state && !with_menu && !sva_svr
%li{ 'data-turbo': turbo ? 'true' : 'false' }
= button_to repasser_en_construction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-draft-line' do
= button_to repasser_en_construction_instructeur_dossier_path(procedure_id, statut: params[:statut], dossier_id:), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-draft-line' do
= t('views.instructeurs.dossiers.repasser_en_construction')

View file

@ -1,5 +1,6 @@
.procedure-header
.clipboard-container
.clipboard-container.flex
= render Instructeurs::BackButtonComponent.new(to: instructeur_procedures_path)
%h1.fr-h3.fr-mb-0
= "#{procedure_libelle procedure} (n°#{procedure.id})"
%nav.fr-nav#navigation{ role: "navigation", "aria-label": t('instructeurs.dossiers.header.banner.procedure_navigation') }
@ -56,7 +57,7 @@
- if @has_export_notification
%span.fr-ml-1v.notifications{ 'aria-label': t('instructeurs.dossiers.header.banner.exports_notification_label') }
%li
= link_to t('instructeurs.dossiers.header.banner.archives'), instructeur_archives_path(procedure), class: 'fr-nav__link'
= link_to t('instructeurs.dossiers.header.banner.archives'), list_instructeur_archives_path(procedure), class: 'fr-nav__link'
%li
= link_to t('instructeurs.dossiers.header.banner.export_templates'), export_templates_instructeur_procedure_path(procedure), class: 'fr-nav__link'

View file

@ -30,7 +30,7 @@
= t('views.instructeurs.dossiers.tab_explainations.suivis')
- if @statut == 'traites'
%p
= t('views.instructeurs.dossiers.tab_explainations.traites_html', archives_path: instructeur_archives_path(@procedure))
= t('views.instructeurs.dossiers.tab_explainations.traites_html', archives_path: list_instructeur_archives_path(@procedure))
- if @statut == 'tous'
%p
- if @procedure.routing_enabled?
@ -111,7 +111,7 @@
- @projected_dossiers.each do |p|
- dossier = p.dossier
- path = instructeur_dossier_path(@procedure, dossier.id)
- path = instructeur_dossier_path(@procedure, dossier.id, statut: params[:statut])
%tr{ class: class_names("file-hidden-by-user" => dossier.hidden_by_user_at.present?), id: "table-dossiers-row-#{dossier.id}", "aria-selected" => "false", "data-row-key" => dossier.id }
- if batch_operation_component.render?
%th.fr-cell--fixed{ scope: 'row' }

View file

@ -42,10 +42,10 @@
= t('relance_effectuee_le', scope: 'views.shared.avis', date: l(avis.reminded_at, format: '%d/%m/%y à %H:%M'))
- if expert_or_instructeur.is_a?(Instructeur)
- if avis.answer.blank?
= link_to(t('remind', scope: 'helpers.label'), remind_instructeur_avis_path(avis.procedure, avis), class:'fr-btn fr-btn--sm fr-btn--tertiary-no-outline', data: { confirm: t('remind', scope: 'helpers.confirmation', email: avis.expert.email) })
= link_to(t('remind', scope: 'helpers.label'), remind_instructeur_avis_path(avis.procedure, params[:statut], avis), class:'fr-btn fr-btn--sm fr-btn--tertiary-no-outline', data: { confirm: t('remind', scope: 'helpers.confirmation', email: avis.expert.email) })
- if avis.revokable_by?(expert_or_instructeur)
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), class:'fr-btn fr-btn--sm fr-btn--tertiary-no-outline', data: { confirm: t('revoke', scope: 'helpers.confirmation', email: avis.expert.email) }, method: :patch)
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, params[:statut], avis), class:'fr-btn fr-btn--sm fr-btn--tertiary-no-outline', data: { confirm: t('revoke', scope: 'helpers.confirmation', email: avis.expert.email) }, method: :patch)
.border-left
- if avis.introduction_file.attached?

View file

@ -468,9 +468,76 @@ Rails.application.routes.draw do
end
end
resources :procedures, only: [:index, :show], param: :procedure_id do
resources :procedures, only: [:index], param: :procedure_id do
member do
resources :archives, only: [:index, :create]
#
# nested navigation, all those route are hit during an instructeur instruction navigation context
# must keep track of last view statut page
#
constraints statut: /a-suivre|suivis|traites|tous|supprimes|expirant|archives/ do
get :show, path: "(:statut)", defaults: { statut: 'a-suivre' } # optional because some url may still live on with /procedure/:id
resources :dossiers, only: [:show, :destroy], param: :dossier_id, path: "(:statut)/dossiers", defaults: { statut: 'a-suivre' } do
member do
resources :commentaires, only: [:destroy]
post 'repousser-expiration' => 'dossiers#extend_conservation'
post 'repousser-expiration-and-restore' => 'dossiers#extend_conservation_and_restore'
post 'dossier_labels' => 'dossiers#dossier_labels'
get 'messagerie'
get 'annotations-privees' => 'dossiers#annotations_privees'
get 'avis'
get 'avis_new'
get 'personnes-impliquees' => 'dossiers#personnes_impliquees'
patch 'follow'
patch 'unfollow'
patch 'archive'
patch 'unarchive'
patch 'restore'
post 'commentaire' => 'dossiers#create_commentaire'
post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
post 'repasser-en-instruction' => 'dossiers#repasser_en_instruction'
post 'terminer'
post 'pending_correction'
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
post 'avis' => 'dossiers#create_avis'
get 'reaffectation'
get 'pieces_jointes'
post 'reaffecter'
end
end
resources :avis, only: [], path: "(:statut)/dossiers", defaults: { statut: 'a-suivre' } do
member do
patch 'revoquer'
get 'remind'
end
end
resources :batch_operations, only: [:create], path: "(:statut)/dossiers", defaults: { statut: 'a-suivre' }
end
#
# not nested navigation
#
resources :dossiers, only: [], param: :dossier_id do
member do
get 'telecharger_pjs' => 'dossiers#telecharger_pjs'
get 'print' => 'dossiers#print'
patch 'annotations' => 'dossiers#update_annotations'
get 'annotations/:stable_id', to: 'dossiers#annotation', as: :annotation
get 'geo_data'
get 'apercu_attestation'
get 'bilans_bdf'
end
end
resources :archives, only: [] do
collection do
get 'list' => "archives#index"
post 'create' => "archives#create"
end
end
resources :groupes, only: [:index, :show], controller: 'groupe_instructeurs' do
resource :contact_information
@ -482,13 +549,6 @@ Rails.application.routes.draw do
end
end
resources :avis, only: [] do
member do
patch 'revoquer'
get 'remind'
end
end
get 'apercu'
get 'download_export'
post 'download_export'
@ -502,45 +562,6 @@ Rails.application.routes.draw do
get 'deleted_dossiers'
get 'email_usagers'
post 'create_multiple_commentaire'
resources :dossiers, only: [:show, :destroy], param: :dossier_id do
member do
resources :commentaires, only: [:destroy]
post 'repousser-expiration' => 'dossiers#extend_conservation'
post 'repousser-expiration-and-restore' => 'dossiers#extend_conservation_and_restore'
post 'dossier_labels' => 'dossiers#dossier_labels'
get 'geo_data'
get 'apercu_attestation'
get 'bilans_bdf'
get 'messagerie'
get 'annotations-privees' => 'dossiers#annotations_privees'
get 'avis'
get 'avis_new'
get 'personnes-impliquees' => 'dossiers#personnes_impliquees'
get 'annotations/:stable_id', to: 'dossiers#annotation', as: :annotation
patch 'follow'
patch 'unfollow'
patch 'archive'
patch 'unarchive'
patch 'restore'
patch 'annotations' => 'dossiers#update_annotations'
post 'commentaire' => 'dossiers#create_commentaire'
post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
post 'repasser-en-instruction' => 'dossiers#repasser_en_instruction'
post 'terminer'
post 'pending_correction'
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
post 'avis' => 'dossiers#create_avis'
get 'print' => 'dossiers#print'
get 'telecharger_pjs' => 'dossiers#telecharger_pjs'
get 'reaffectation'
get 'pieces_jointes'
post 'reaffecter'
end
end
resources :batch_operations, only: [:create]
end
end
end

View file

@ -5,6 +5,15 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
let(:procedure) { create(:procedure) }
subject { render_inline(component).to_html }
let(:component) do
described_class.new(
batch: batch_operation,
procedure:
)
end
before do
allow(component).to receive(:procedure_path).and_return(Rails.application.routes.url_helpers.instructeur_procedure_path(procedure, statut: 'a-suivre'))
end
describe 'archiver' do
let(:component) do
@ -54,7 +63,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -108,7 +117,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -162,7 +171,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -216,7 +225,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -270,7 +279,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -396,7 +405,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -450,7 +459,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -504,7 +513,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -558,7 +567,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end
@ -612,7 +621,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
it { expect(batch_operation.seen_at).to eq(nil) }
it 'on next render "seen_at" is set to avoid rendering alert' do
render_inline(component).to_html
render_inline(described_class.new(batch: batch_operation, procedure:)).to_html
expect(batch_operation.seen_at).not_to eq(nil)
end
end

View file

@ -10,6 +10,10 @@ RSpec.describe Dossiers::MessageComponent, type: :component do
groupe_gestionnaire: groupe_gestionnaire
)
end
before do
allow(component).to receive(:params).and_return({ statut: 'a-suivre' })
end
let(:seen_at) { commentaire.created_at + 1.hour }
describe 'for dossier' do
@ -230,7 +234,7 @@ RSpec.describe Dossiers::MessageComponent, type: :component do
describe 'delete message button for gestionnaire' do
let(:connected_user) { gestionnaire }
let(:form_url) { component.helpers.gestionnaire_groupe_gestionnaire_commentaire_path(groupe_gestionnaire, commentaire) }
let(:form_url) { component.helpers.gestionnaire_groupe_gestionnaire_commentaire_path(groupe_gestionnaire, commentaire, statut: 'a-suivre') }
context 'when commentaire had been written by connected gestionnaire' do
it { is_expected.to have_selector("form[action=\"#{form_url}\"]") }

View file

@ -4,7 +4,9 @@ RSpec.describe Instructeurs::EnConstructionMenuComponent, type: :component do
include DossierHelper
subject do
render_inline(described_class.new(dossier:))
component = described_class.new(dossier:)
allow(component).to receive(:statut).and_return('a-suivre')
render_inline(component)
end
matcher :have_dropdown_title do |expected_title|

View file

@ -19,7 +19,7 @@ describe Instructeurs::AvisController, type: :controller do
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
before do
patch :revoquer, params: { procedure_id: procedure.id, id: avis.id }
patch :revoquer, params: { procedure_id: procedure.id, id: avis.id, statut: 'a-suivre' }
end
it "revoke the dossier" do
@ -35,7 +35,7 @@ describe Instructeurs::AvisController, type: :controller do
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
it 'sends a reminder to the expert' do
get :remind, params: { procedure_id: procedure.id, id: avis.id }
get :remind, params: { procedure_id: procedure.id, id: avis.id, statut: 'a-suivre' }
expect(AvisMailer).to have_received(:avis_invitation_and_confirm_email)
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
expect(avis.reload.reminded_at).to be_present
@ -46,7 +46,7 @@ describe Instructeurs::AvisController, type: :controller do
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, question_label: '123') }
it 'sends a reminder to the expert' do
get :remind, params: { procedure_id: procedure.id, id: avis.id }
get :remind, params: { procedure_id: procedure.id, id: avis.id, statut: 'a-suivre' }
expect(AvisMailer).to have_received(:avis_invitation_and_confirm_email)
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
expect(avis.reload.reminded_at).to be_present

View file

@ -10,7 +10,8 @@ describe Instructeurs::BatchOperationsController, type: :controller do
batch_operation: {
operation: BatchOperation.operations.fetch(:archiver),
dossier_ids: [dossier.id]
}
},
statut: 'a-suivre'
}
end
@ -20,7 +21,10 @@ describe Instructeurs::BatchOperationsController, type: :controller do
context 'ACL' do
let(:params) do
{ procedure_id: create(:procedure).id }
{
procedure_id: create(:procedure).id,
statut: 'a-suivre'
}
end
it 'fails when procedure does not belongs to instructeur' do

View file

@ -13,7 +13,7 @@ describe Instructeurs::CommentairesController, type: :controller do
describe 'destroy' do
context 'when it works' do
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id }, format: :turbo_stream }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'respond with OK and flash' do
expect(subject).to have_http_status(:ok)
@ -48,7 +48,7 @@ describe Instructeurs::CommentairesController, type: :controller do
context 'when dossier had been discarded' do
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier, discarded_at: 2.hours.ago) }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id }, format: :turbo_stream }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'respond with OK and flash' do
expect(subject).to have_http_status(:ok)
@ -65,7 +65,7 @@ describe Instructeurs::CommentairesController, type: :controller do
describe 'destroy' do
context 'when it works' do
let(:commentaire) { create(:commentaire, expert: expert, dossier: dossier) }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id }, format: :turbo_stream }
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'respond with OK and flash' do
expect(subject).to have_http_status(:ok)

View file

@ -33,7 +33,8 @@ describe Instructeurs::DossiersController, type: :controller do
params: {
recipients: [recipient.id],
procedure_id: procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
)
end
@ -64,7 +65,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject do
batch_operation
patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id }
patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }
end
it do
@ -93,7 +94,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject do
batch_operation
patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id }
patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }
end
it do
@ -121,7 +122,7 @@ describe Instructeurs::DossiersController, type: :controller do
let(:batch_operation) {}
before do
batch_operation
patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id }
patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }
dossier.reload
instructeur.follow(dossier)
end
@ -142,7 +143,7 @@ describe Instructeurs::DossiersController, type: :controller do
before do
batch_operation
dossier.update(archived: true)
patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id }
patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }
end
it { expect(dossier.reload.archived).to eq(false) }
@ -162,7 +163,7 @@ describe Instructeurs::DossiersController, type: :controller do
before do
batch_operation
sign_in(instructeur.user)
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream
end
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
@ -208,7 +209,7 @@ describe Instructeurs::DossiersController, type: :controller do
batch_operation
sign_in(instructeur.user)
post :repasser_en_construction,
params: { procedure_id: procedure.id, dossier_id: dossier.id },
params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' },
format: :turbo_stream
end
@ -243,7 +244,7 @@ describe Instructeurs::DossiersController, type: :controller do
sign_in current_user
batch_operation
post :repasser_en_instruction,
params: { procedure_id: procedure.id, dossier_id: dossier.id },
params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' },
format: :turbo_stream
end
@ -297,7 +298,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
context 'simple refusal' do
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'change state to refuse' do
subject
@ -321,7 +322,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
context 'refusal with a justificatif' do
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif }, statut: 'a-suivre' }, format: :turbo_stream }
it 'attachs a justificatif' do
subject
@ -336,7 +337,7 @@ describe Instructeurs::DossiersController, type: :controller do
context 'with dossier in batch_operation' do
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier], instructeur: instructeur) }
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream }
it { expect { subject }.not_to change { dossier.reload.state } }
it { is_expected.to redirect_to(instructeur_dossier_path(dossier.procedure, dossier)) }
@ -353,7 +354,7 @@ describe Instructeurs::DossiersController, type: :controller do
sign_in(instructeur.user)
end
context 'without continuation' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier_for_tiers.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier_for_tiers.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'Notification email is sent' do
expect(NotificationMailer).to receive(:send_sans_suite_notification)
@ -379,7 +380,7 @@ describe Instructeurs::DossiersController, type: :controller do
sign_in(instructeur.user)
end
context 'without continuation' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier_for_tiers_without_notif.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier_for_tiers_without_notif.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'Notification email is sent' do
expect(NotificationMailer).to receive(:send_sans_suite_notification)
@ -405,7 +406,7 @@ describe Instructeurs::DossiersController, type: :controller do
sign_in(instructeur.user)
end
context 'with classer_sans_suite' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure_accuse_lecture.id, dossier_id: dossier_accuse_lecture.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure_accuse_lecture.id, dossier_id: dossier_accuse_lecture.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'Notification accuse de lecture email is sent and not the others' do
expect(NotificationMailer).to receive(:send_accuse_lecture_notification)
@ -433,7 +434,7 @@ describe Instructeurs::DossiersController, type: :controller do
sign_in(instructeur.user)
end
context 'without attachment' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'change state to sans_suite' do
subject
@ -458,7 +459,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
context 'with attachment' do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre', dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
it 'change state to sans_suite' do
subject
@ -484,7 +485,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(NotificationMailer).to receive(:deliver_later)
end
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream }
it 'change state to accepte' do
subject
@ -532,7 +533,8 @@ describe Instructeurs::DossiersController, type: :controller do
process_action: "accepter",
procedure_id: procedure.id,
dossier_id: dossier.id,
dossier: { motivation: "Yallah" }
dossier: { motivation: "Yallah" },
statut: 'a-suivre'
}, format: :turbo_stream
end
@ -546,7 +548,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
context 'with an attachment' do
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif }, statut: 'a-suivre' }, format: :turbo_stream }
it 'change state to accepte' do
subject
@ -564,7 +566,7 @@ describe Instructeurs::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, for_individual: false, instructeurs: instructeurs) }
let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure, as_degraded_mode: true) }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }, format: :turbo_stream }
context "with accepter" do
it 'warns about the error' do
@ -583,7 +585,7 @@ describe Instructeurs::DossiersController, type: :controller do
before { allow(dossier).to receive(:after_accepter) }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: :turbo_stream }
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif }, statut: 'a-suivre' }, format: :turbo_stream }
it 'does not close it again' do
subject
@ -604,7 +606,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject do
post :pending_correction, params: {
procedure_id: procedure.id, dossier_id: dossier.id,
procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre',
dossier: { motivation: message, justificatif_motivation: justificatif },
reason:
}, format: :turbo_stream
@ -713,7 +715,7 @@ describe Instructeurs::DossiersController, type: :controller do
describe '#messagerie' do
before { expect(controller.current_instructeur).to receive(:mark_tab_as_seen).with(dossier, :messagerie) }
subject { get :messagerie, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
subject { get :messagerie, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' } }
it { expect(subject).to have_http_status(:ok) }
end
@ -731,7 +733,8 @@ describe Instructeurs::DossiersController, type: :controller do
commentaire: {
body: body,
file: file
}
},
statut: 'a-suivre'
}
}
@ -794,7 +797,8 @@ describe Instructeurs::DossiersController, type: :controller do
post :create_avis, params: {
procedure_id: procedure.id,
dossier_id: dossier.id,
avis: { emails: emails, introduction: 'intro', confidentiel: true, invite_linked_dossiers: invite_linked_dossiers, claimant: instructeur, experts_procedure: experts_procedure }
avis: { emails: emails, introduction: 'intro', confidentiel: true, invite_linked_dossiers: invite_linked_dossiers, claimant: instructeur, experts_procedure: experts_procedure },
statut: 'a-suivre'
}
end
@ -949,6 +953,7 @@ describe Instructeurs::DossiersController, type: :controller do
get :show, params: {
procedure_id: procedure.id,
dossier_id: dossier.id,
statut: 'a-suivre',
format: :pdf
}
end
@ -973,7 +978,7 @@ describe Instructeurs::DossiersController, type: :controller do
context 'with dossier in batch_operation' do
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier], instructeur: instructeur) }
it 'assigns variable with true value' do
get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id }
get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' }
expect(assigns(:is_dossier_in_batch_operation)).to eq(true)
end
end
@ -1181,7 +1186,8 @@ describe Instructeurs::DossiersController, type: :controller do
batch_operation
delete :destroy, params: {
procedure_id: procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
end
@ -1267,7 +1273,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
describe '#extend_conservation' do
subject { post :extend_conservation, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
subject { post :extend_conservation, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' } }
context 'when user logged in' do
it 'works' do
expect(subject).to redirect_to(instructeur_dossier_path(procedure, dossier))
@ -1308,7 +1314,8 @@ describe Instructeurs::DossiersController, type: :controller do
patch :restore,
params: {
procedure_id: procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
end
@ -1325,7 +1332,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
describe '#extend_conservation and restore' do
subject { post :extend_conservation_and_restore, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
subject { post :extend_conservation_and_restore, params: { procedure_id: procedure.id, dossier_id: dossier.id, statut: 'a-suivre' } }
before do
dossier.update(hidden_by_expired_at: 1.hour.ago, hidden_by_reason: 'expired')
@ -1398,7 +1405,8 @@ describe Instructeurs::DossiersController, type: :controller do
post :reaffectation,
params: {
procedure_id: procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
end
@ -1423,7 +1431,8 @@ describe Instructeurs::DossiersController, type: :controller do
params: {
procedure_id: procedure.id,
dossier_id: dossier.id,
groupe_instructeur_id: gi_2.id
groupe_instructeur_id: gi_2.id,
statut: 'a-suivre'
}
end
@ -1458,7 +1467,8 @@ describe Instructeurs::DossiersController, type: :controller do
get :personnes_impliquees,
params: {
procedure_id: routed_procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
end
@ -1514,7 +1524,8 @@ describe Instructeurs::DossiersController, type: :controller do
get :pieces_jointes, params: {
procedure_id: procedure.id,
dossier_id: dossier.id
dossier_id: dossier.id,
statut: 'a-suivre'
}
end
@ -1535,7 +1546,7 @@ describe Instructeurs::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :with_labels, instructeurs: [instructeur]) }
let!(:dossier) { create(:dossier, :en_construction, procedure:) }
context 'it create dossier labels' do
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [Label.first.id] }, format: :turbo_stream }
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [Label.first.id], statut: 'a-suivre' }, format: :turbo_stream }
it 'works' do
subject
dossier.reload
@ -1551,7 +1562,7 @@ describe Instructeurs::DossiersController, type: :controller do
DossierLabel.create(dossier_id: dossier.id, label_id: dossier.procedure.labels.first.id)
end
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [] }, format: :turbo_stream }
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [], statut: 'a-suivre' }, format: :turbo_stream }
it 'works' do
expect(dossier.dossier_labels.count).to eq(1)

View file

@ -263,7 +263,7 @@ describe Instructeurs::ProceduresController, type: :controller do
let!(:gi_2) { create(:groupe_instructeur, label: '2', procedure: procedure) }
let!(:gi_3) { create(:groupe_instructeur, label: '3', procedure: procedure) }
let(:statut) { nil }
let(:statut) { 'a-suivre' }
subject do
get :show, params: { procedure_id: procedure.id, statut: statut }

View file

@ -38,7 +38,16 @@ describe 'Instructing a dossier:', js: true do
expect(page).to have_current_path(instructeur_procedure_path(procedure))
click_on dossier.user.email
expect(page).to have_current_path(instructeur_dossier_path(procedure, dossier))
expect(page).to have_current_path(instructeur_dossier_path(procedure, dossier, statut: 'a-suivre'))
page.find('.back-btn').click
click_on 'Suivre le dossier'
click_on 'suivi'
expect(page).to have_current_path(instructeur_procedure_path(procedure, statut: 'suivis'))
click_on dossier.user.email
expect(page).to have_current_path(instructeur_dossier_path(procedure, 'suivis', dossier))
expect(page).to have_selector(".back-btn[href=\"#{instructeur_procedure_path(procedure, statut: 'suivis')}\"]")
click_on 'Passer en instruction'
@ -70,16 +79,17 @@ describe 'Instructing a dossier:', js: true do
dossier.reload
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
expect(dossier.motivation).to eq('a good reason')
# keep back up to date after most action on dossier
expect(page).to have_selector(".back-btn[href=\"#{instructeur_procedure_path(procedure, statut: 'suivis')}\"]")
click_on procedure.libelle
click_on 'traité'
expect(page).to have_button('Repasser en instruction')
click_on 'Supprimer le dossier'
click_on 'traité'
expect(page).not_to have_button('Repasser en instruction')
end
scenario 'An instructeur can add anotations' do
scenario 'An instructeur can add annotations' do
log_in(instructeur.email, password)
visit instructeur_dossier_path(procedure, dossier)
@ -92,15 +102,6 @@ describe 'Instructing a dossier:', js: true do
expect(page).to have_text 'Annotations enregistrées'
end
scenario 'An instructeur can destroy a dossier from view' do
log_in(instructeur.email, password)
dossier.passer_en_instruction(instructeur: instructeur)
dossier.accepter!(instructeur: instructeur)
visit instructeur_dossier_path(procedure, dossier)
click_on 'Supprimer le dossier'
end
scenario 'A instructeur can follow/unfollow a dossier' do
log_in(instructeur.email, password)
@ -152,18 +153,20 @@ describe 'Instructing a dossier:', js: true do
expect(page).to have_text('Télécharger lexport')
end
scenario 'A instructeur can see the personnes impliquées' do
scenario 'A instructeur can see the personnes impliquées and statut is maintened over avis/personnes impliquee paths', chrome: true do
instructeur2 = create(:instructeur, password: password)
log_in(instructeur.email, password)
click_on procedure.libelle
click_on 'Suivre le dossier'
click_on 'suivi'
click_on dossier.user.email
click_on 'Avis externes'
expect(page).to have_current_path(avis_instructeur_dossier_path(procedure, dossier))
expect(page).to have_current_path(avis_instructeur_dossier_path(procedure, dossier, statut: 'suivis'))
within('.fr-sidemenu') { click_on 'Demander un avis' }
expect(page).to have_current_path(avis_new_instructeur_dossier_path(procedure, dossier))
expect(page).to have_current_path(avis_new_instructeur_dossier_path(procedure, dossier, statut: 'suivis'))
expert_email = 'expert@tps.com'
ask_confidential_avis(expert_email, 'a good introduction')
@ -171,6 +174,7 @@ describe 'Instructing a dossier:', js: true do
ask_confidential_avis(instructeur2.email, 'a good introduction')
click_on 'Personnes impliquées'
expect(page).to have_current_path(personnes_impliquees_instructeur_dossier_path(procedure, dossier, statut: 'suivis'))
expect(page).to have_text(expert_email)
expect(page).to have_text(instructeur2.email)
end
@ -199,20 +203,19 @@ describe 'Instructing a dossier:', js: true do
expect(page).to have_text("Dossier envoyé")
end
context 'A instructeur can ask for an Archive' do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs: [instructeur]) }
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
before do
scenario 'A instructeur can ask for an Archive', chrome: true do
archivable_procedure = create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs: [instructeur])
create(:dossier, :accepte, procedure: archivable_procedure)
log_in(instructeur.email, password)
visit instructeur_archives_path(procedure)
end
scenario 'download' do
visit list_instructeur_archives_path(archivable_procedure)
expect {
page.first(".fr-table .fr-btn").click
}.to have_enqueued_job(ArchiveCreationJob).with(procedure, an_instance_of(Archive), instructeur)
}.to have_enqueued_job(ArchiveCreationJob).with(archivable_procedure, an_instance_of(Archive), instructeur)
expect(Archive.first.month).not_to be_nil
end
end
context 'with dossiers having attached files' do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs: [instructeur]) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }

View file

@ -216,7 +216,7 @@ describe 'The routing with rules', js: true do
## on the dossier itself
click_on 'suivi'
click_on litteraire_user.email
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first, statut: :suivis))
expect(page).to have_text('Annotations privées')
expect(find('.fr-tabs')).to have_css('span.notifications')
log_out
@ -231,7 +231,7 @@ describe 'The routing with rules', js: true do
# the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litteraire dossiers
register_instructeur_and_log_in(alain.email)
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
visit instructeur_procedure_path(procedure, statut: 'tous')
expect(page).to have_text(litteraire_user.email)
expect(page).to have_text(scientifique_user.email)
@ -239,7 +239,7 @@ describe 'The routing with rules', js: true do
click_on scientifique_user.email
click_on 'Suivre le dossier'
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
visit instructeur_procedure_path(procedure, statut: 'tous')
click_on litteraire_user.email
click_on 'Suivre le dossier'
log_out

View file

@ -4,6 +4,7 @@ describe 'instructeurs/dossiers/instruction_button_motivation', type: :view do
let(:dossier) { create(:dossier, :en_instruction) }
subject do
allow(controller).to receive(:params).and_return(statut: 'a-suivre')
render(
'instructeurs/dossiers/instruction_button_motivation',
dossier: dossier,

View file

@ -7,6 +7,7 @@ describe 'instructeurs/dossiers/annotations_privees', type: :view do
before do
sign_in(current_instructeur.user)
allow(view).to receive(:current_instructeur).and_return(current_instructeur)
allow(controller).to receive(:params).and_return({ statut: 'a-suivre' })
assign(:dossier, dossier)
end

View file

@ -7,6 +7,7 @@ describe 'instructeurs/dossiers/show', type: :view do
before do
sign_in(current_instructeur.user)
allow(view).to receive(:current_instructeur).and_return(current_instructeur)
allow(controller).to receive(:params).and_return(statut: 'a-suivre')
assign(:dossier, dossier)
end

View file

@ -1,7 +1,10 @@
# frozen_string_literal: true
describe 'shared/avis/_list', type: :view do
before { view.extend DossierHelper }
before do
view.extend DossierHelper
allow(view).to receive(:params).and_return({ statut: 'a-suivre' })
end
subject { render 'shared/avis/list', avis: avis, avis_seen_at: seen_at, expert_or_instructeur: instructeur }