Merge pull request #6628 from betagouv/feat/6536

ETQ usager, je veux pouvoir supprimer les dossiers terminés
This commit is contained in:
Kara Diaby 2021-11-26 09:51:28 +01:00 committed by GitHub
commit 783b0ed9f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 135 additions and 51 deletions

View file

@ -83,3 +83,11 @@
width: 200px; width: 200px;
} }
} }
.file-hidden-by-user {
background-color: rgba(242, 137, 0, 0.6);
&:hover {
background-color: rgba(242, 137, 0, 0.6) !important;
}
}

View file

@ -16,7 +16,8 @@ module Users
before_action :store_user_location!, only: :new before_action :store_user_location!, only: :new
def index def index
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) @user_dossiers = current_user.dossiers.includes(:procedure).not_termine.order_by_updated_at.page(page)
@dossiers_traites = current_user.dossiers.includes(:procedure).termine.not_hidden_by_user.order_by_updated_at.page(page)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
@dossiers_supprimes = current_user.deleted_dossiers.order_by_updated_at.page(page) @dossiers_supprimes = current_user.deleted_dossiers.order_by_updated_at.page(page)
@dossier_transfers = DossierTransfer @dossier_transfers = DossierTransfer
@ -25,7 +26,7 @@ module Users
.where(email: current_user.email) .where(email: current_user.email)
.page(page) .page(page)
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.page(page) @dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.page(page)
@statut = statut(@user_dossiers, @dossiers_invites, @dossiers_supprimes, @dossier_transfers, @dossiers_close_to_expiration, params[:statut]) @statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
end end
def show def show
@ -287,14 +288,22 @@ module Users
@transfer = DossierTransfer.new(dossiers: current_user.dossiers) @transfer = DossierTransfer.new(dossiers: current_user.dossiers)
end end
def hide_dossier
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
dossier.update(hidden_by_user_at: Time.zone.now)
flash.notice = t('users.dossiers.ask_deletion.deleted_dossier')
redirect_to dossiers_path
end
private private
# if the status tab is filled, then this tab # if the status tab is filled, then this tab
# else first filled tab # else first filled tab
# else mes-dossiers # else en-cours
def statut(mes_dossiers, dossiers_invites, dossiers_supprimes, dossier_transfers, dossiers_close_to_expiration, params_statut) def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes, dossier_transfers, dossiers_close_to_expiration, params_statut)
tabs = { tabs = {
'mes-dossiers' => mes_dossiers.present?, 'en-cours' => mes_dossiers.present?,
'traites' => dossiers_traites.present?,
'dossiers-invites' => dossiers_invites.present?, 'dossiers-invites' => dossiers_invites.present?,
'dossiers-supprimes' => dossiers_supprimes.present?, 'dossiers-supprimes' => dossiers_supprimes.present?,
'dossiers-transferes' => dossier_transfers.present?, 'dossiers-transferes' => dossier_transfers.present?,
@ -306,7 +315,7 @@ module Users
tabs tabs
.filter { |_tab, filled| filled } .filter { |_tab, filled| filled }
.map { |tab, _| tab } .map { |tab, _| tab }
.first || 'mes-dossiers' .first || 'en-cours'
end end
end end

View file

@ -16,6 +16,7 @@
# en_instruction_at :datetime # en_instruction_at :datetime
# groupe_instructeur_updated_at :datetime # groupe_instructeur_updated_at :datetime
# hidden_at :datetime # hidden_at :datetime
# hidden_by_user_at :datetime
# identity_updated_at :datetime # identity_updated_at :datetime
# last_avis_updated_at :datetime # last_avis_updated_at :datetime
# last_champ_private_updated_at :datetime # last_champ_private_updated_at :datetime
@ -206,9 +207,11 @@ class Dossier < ApplicationRecord
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) } scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) }
scope :state_termine, -> { where(state: TERMINE) } scope :state_termine, -> { where(state: TERMINE) }
scope :state_not_termine, -> { where.not(state: TERMINE) }
scope :archived, -> { where(archived: true) } scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) } scope :not_archived, -> { where(archived: false) }
scope :not_hidden_by_user, -> { where(hidden_by_user_at: nil) }
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) } scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
scope :order_by_created_at, -> (order = :asc) { order(en_construction_at: order, created_at: order, id: order) } scope :order_by_created_at, -> (order = :asc) { order(en_construction_at: order, created_at: order, id: order) }
@ -229,6 +232,7 @@ class Dossier < ApplicationRecord
scope :en_construction, -> { not_archived.state_en_construction } scope :en_construction, -> { not_archived.state_en_construction }
scope :en_instruction, -> { not_archived.state_en_instruction } scope :en_instruction, -> { not_archived.state_en_instruction }
scope :termine, -> { not_archived.state_termine } scope :termine, -> { not_archived.state_termine }
scope :not_termine, -> { state_not_termine }
scope :processed_in_month, -> (month) do scope :processed_in_month, -> (month) do
state_termine state_termine
.joins(:traitements) .joins(:traitements)
@ -1091,6 +1095,10 @@ class Dossier < ApplicationRecord
end end
end end
def hidden_by_user?
self.hidden_by_user_at.present?
end
private private
def create_missing_traitemets def create_missing_traitemets

View file

@ -1,5 +1,5 @@
class DossierProjectionService class DossierProjectionService
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :columns) class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :columns)
end end
TABLE = 'table' TABLE = 'table'
@ -20,8 +20,9 @@ class DossierProjectionService
def self.project(dossiers_ids, fields) def self.project(dossiers_ids, fields)
state_field = { TABLE => 'self', COLUMN => 'state' } state_field = { TABLE => 'self', COLUMN => 'state' }
archived_field = { TABLE => 'self', COLUMN => 'archived' } archived_field = { TABLE => 'self', COLUMN => 'archived' }
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
([state_field, archived_field] + fields) # the view needs state and archived dossier attributes ([state_field, archived_field, hidden_by_user_at_field] + fields) # the view needs state and archived dossier attributes
.each { |f| f[:id_value_h] = {} } .each { |f| f[:id_value_h] = {} }
.group_by { |f| f[TABLE] } # one query per table .group_by { |f| f[TABLE] } # one query per table
.each do |table, fields| .each do |table, fields|
@ -45,7 +46,7 @@ class DossierProjectionService
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym }) .pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
.each do |id, *columns| .each do |id, *columns|
fields.zip(columns).each do |field, value| fields.zip(columns).each do |field, value|
if [state_field, archived_field].include?(field) if [state_field, archived_field, hidden_by_user_at_field].include?(field)
field[:id_value_h][id] = value field[:id_value_h][id] = value
else else
field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime
@ -98,6 +99,7 @@ class DossierProjectionService
dossier_id, dossier_id,
state_field[:id_value_h][dossier_id], state_field[:id_value_h][dossier_id],
archived_field[:id_value_h][dossier_id], archived_field[:id_value_h][dossier_id],
hidden_by_user_at_field[:id_value_h][dossier_id],
fields.map { |f| f[:id_value_h][dossier_id] } fields.map { |f| f[:id_value_h][dossier_id] }
) )
end end

View file

@ -11,7 +11,7 @@
= link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path), class: ['button large expand'] = link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path), class: ['button large expand']
- else - else
- dossiers = current_user.dossiers.where(revision: @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id)) - dossiers = current_user.dossiers.where(hidden_by_user_at: nil, revision: @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id))
- drafts = dossiers.merge(Dossier.state_brouillon) - drafts = dossiers.merge(Dossier.state_brouillon)
- not_drafts = dossiers.merge(Dossier.state_not_brouillon) - not_drafts = dossiers.merge(Dossier.state_not_brouillon)

View file

@ -100,8 +100,7 @@
%tbody %tbody
- @projected_dossiers.each do |p| - @projected_dossiers.each do |p|
- path = instructeur_dossier_path(@procedure, p.dossier_id) - path = instructeur_dossier_path(@procedure, p.dossier_id)
%tr{ class: [p.hidden_by_user_at.present? && "file-hidden-by-user"] }
%tr
%td.folder-col %td.folder-col
%a.cell-link{ href: path } %a.cell-link{ href: path }
%span.icon.folder %span.icon.folder
@ -113,7 +112,9 @@
- p.columns.each do |column| - p.columns.each do |column|
%td %td
%a.cell-link{ href: path }= column %a.cell-link{ href: path }
= column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
%td.status-col %td.status-col
%a.cell-link{ href: path }= status_badge(p.state) %a.cell-link{ href: path }= status_badge(p.state)

View file

@ -2,7 +2,8 @@
- has_delete_action = dossier.can_be_deleted_by_user? - has_delete_action = dossier.can_be_deleted_by_user?
- has_new_dossier_action = dossier.procedure.accepts_new_dossiers? - has_new_dossier_action = dossier.procedure.accepts_new_dossiers?
- has_transfer_action = dossier.user == current_user - has_transfer_action = dossier.user == current_user
- has_actions = has_edit_action || has_delete_action || has_new_dossier_action || has_transfer_action - has_hide_action = dossier.termine? && dossier.hidden_by_user_at.nil?
- has_actions = has_edit_action || has_delete_action || has_new_dossier_action || has_transfer_action || has_hide_action
- if has_actions - if has_actions
.dropdown.user-dossier-actions .dropdown.user-dossier-actions
@ -44,3 +45,10 @@
%span.icon.delete %span.icon.delete
.dropdown-description .dropdown-description
= t('views.users.dossiers.dossier_action.delete_dossier') = t('views.users.dossiers.dossier_action.delete_dossier')
- if has_hide_action
%li
= link_to hide_dossier_dossier_path(dossier), method: :patch do
%span.icon.delete
.dropdown-description
= t('views.users.dossiers.dossier_action.hide_dossier')

View file

@ -15,25 +15,31 @@
- else - else
%h1.page-title= t('views.users.dossiers.index.dossiers') %h1.page-title= t('views.users.dossiers.index.dossiers')
%ul.tabs %ul.tabs
- if @user_dossiers.count > 0 - if @user_dossiers.present?
= tab_item(t('pluralize.mes_dossiers', count: @user_dossiers.count), = tab_item(t('pluralize.en_cours', count: @user_dossiers.count),
dossiers_path(statut: 'mes-dossiers'), dossiers_path(statut: 'en-cours'),
active: @statut == 'mes-dossiers', active: @statut == 'en-cours',
badge: number_with_html_delimiter(@user_dossiers.count)) badge: number_with_html_delimiter(@user_dossiers.count))
- if @dossiers_invites.count > 0 - if @dossiers_traites.present?
= tab_item(t('pluralize.traites', count: @dossiers_traites.count),
dossiers_path(statut: 'traites'),
active: @statut == 'traites',
badge: number_with_html_delimiter(@dossiers_traites.count))
- if @dossiers_invites.present?
= tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count), = tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count),
dossiers_path(statut: 'dossiers-invites'), dossiers_path(statut: 'dossiers-invites'),
active: @statut == 'dossiers-invites', active: @statut == 'dossiers-invites',
badge: number_with_html_delimiter(@dossiers_invites.count)) badge: number_with_html_delimiter(@dossiers_invites.count))
- if @dossiers_supprimes.count > 0 - if @dossiers_supprimes.present?
= tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count), = tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count),
dossiers_path(statut: 'dossiers-supprimes'), dossiers_path(statut: 'dossiers-supprimes'),
active: @statut == 'dossiers-supprimes', active: @statut == 'dossiers-supprimes',
badge: number_with_html_delimiter(@dossiers_supprimes.count)) badge: number_with_html_delimiter(@dossiers_supprimes.count))
- if @dossier_transfers.count > 0 - if @dossier_transfers.present?
= tab_item(t('pluralize.dossiers_transferes', count: @dossier_transfers.count), = tab_item(t('pluralize.dossiers_transferes', count: @dossier_transfers.count),
dossiers_path(statut: 'dossiers-transferes'), dossiers_path(statut: 'dossiers-transferes'),
active: @statut == 'dossiers-transferes', active: @statut == 'dossiers-transferes',
@ -46,9 +52,12 @@
badge: number_with_html_delimiter(@dossiers_close_to_expiration.count)) badge: number_with_html_delimiter(@dossiers_close_to_expiration.count))
.container .container
- if @statut == "mes-dossiers" - if @statut == "en-cours"
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers } = render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
- if @statut == "traites"
= render partial: "dossiers_list", locals: { dossiers: @dossiers_traites }
- if @statut == "dossiers-invites" - if @statut == "dossiers-invites"
= render partial: "dossiers_list", locals: { dossiers: @dossiers_invites } = render partial: "dossiers_list", locals: { dossiers: @dossiers_invites }

View file

@ -132,6 +132,9 @@ en:
form: "Form" form: "Form"
edit_siret: "Edit SIRET" edit_siret: "Edit SIRET"
edit_identity: "Edit identity data" edit_identity: "Edit identity data"
instructeurs:
dossiers:
deleted_by_user: "File deleted by user"
users: users:
dossiers: dossiers:
autosave: autosave:
@ -191,6 +194,7 @@ en:
edit_dossier: "Edit the file" edit_dossier: "Edit the file"
start_other_dossier: "Start an other file" start_other_dossier: "Start an other file"
delete_dossier: "Delete the file" delete_dossier: "Delete the file"
hide_dossier: "Delete from your screen"
transfer_dossier: "Transfer the file" transfer_dossier: "Transfer the file"
edit_draft: "Edit the draft" edit_draft: "Edit the draft"
actions: "Actions" actions: "Actions"
@ -326,10 +330,14 @@ en:
zero: archived zero: archived
one: archived one: archived
other: archived other: archived
mes_dossiers: en_cours:
zero: my file zero: in progress
one: my file one: in progress
other: my files other: in progress
traites:
zero: finished
one: finished
other: finished
dossiers_invites: dossiers_invites:
zero: guest file zero: guest file
one: guest file one: guest file

View file

@ -128,6 +128,9 @@ fr:
form: "Formulaire" form: "Formulaire"
edit_siret: "Modifier le SIRET" edit_siret: "Modifier le SIRET"
edit_identity: "Modifier lidentité" edit_identity: "Modifier lidentité"
instructeurs:
dossiers:
deleted_by_user: "Dossier supprimé par l'usager"
users: users:
dossiers: dossiers:
autosave: autosave:
@ -187,6 +190,7 @@ fr:
edit_dossier: "Modifier le dossier" edit_dossier: "Modifier le dossier"
start_other_dossier: "Commencer un autre dossier" start_other_dossier: "Commencer un autre dossier"
delete_dossier: "Supprimer le dossier" delete_dossier: "Supprimer le dossier"
hide_dossier: "Supprimer de votre interface"
transfer_dossier: "Transferer le dossier" transfer_dossier: "Transferer le dossier"
edit_draft: "Modifier le brouillon" edit_draft: "Modifier le brouillon"
actions: "Actions" actions: "Actions"
@ -334,10 +338,14 @@ fr:
zero: archivé zero: archivé
one: archivé one: archivé
other: archivés other: archivés
mes_dossiers: en_cours:
zero: mon dossier zero: en cours
one: mon dossier one: en cours
other: mes dossiers other: en cours
traites:
zero: traité
one: traité
other: traités
dossiers_invites: dossiers_invites:
zero: dossier invité zero: dossier invité
one: dossier invité one: dossier invité

View file

@ -268,6 +268,7 @@ Rails.application.routes.draw do
get 'messagerie' get 'messagerie'
post 'commentaire' => 'dossiers#create_commentaire' post 'commentaire' => 'dossiers#create_commentaire'
post 'ask_deletion' post 'ask_deletion'
patch 'hide_dossier'
get 'attestation' get 'attestation'
get 'transferer', to: 'dossiers#transferer' get 'transferer', to: 'dossiers#transferer'
end end

View file

@ -0,0 +1,5 @@
class AddHideByUserAtOnDossiers < ActiveRecord::Migration[6.1]
def change
add_column :dossiers, :hidden_by_user_at, :datetime
end
end

View file

@ -324,6 +324,7 @@ ActiveRecord::Schema.define(version: 2021_11_24_111429) do
t.bigint "dossier_transfer_id" t.bigint "dossier_transfer_id"
t.datetime "identity_updated_at" t.datetime "identity_updated_at"
t.datetime "depose_at" t.datetime "depose_at"
t.datetime "hidden_by_user_at"
t.index ["archived"], name: "index_dossiers_on_archived" t.index ["archived"], name: "index_dossiers_on_archived"
t.index ["dossier_transfer_id"], name: "index_dossiers_on_dossier_transfer_id" t.index ["dossier_transfer_id"], name: "index_dossiers_on_dossier_transfer_id"
t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id" t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id"

View file

@ -793,14 +793,14 @@ describe Users::DossiersController, type: :controller do
context 'when the user does not have any dossiers' do context 'when the user does not have any dossiers' do
before { get(:index) } before { get(:index) }
it { expect(assigns(:statut)).to eq('mes-dossiers') } it { expect(assigns(:statut)).to eq('en-cours') }
end end
context 'when the user only have its own dossiers' do context 'when the user only have its own dossiers' do
let!(:own_dossier) { create(:dossier, user: user) } let!(:own_dossier) { create(:dossier, user: user) }
before { get(:index) } before { get(:index) }
it { expect(assigns(:statut)).to eq('mes-dossiers') } it { expect(assigns(:statut)).to eq('en-cours') }
it { expect(assigns(:user_dossiers)).to match([own_dossier]) } it { expect(assigns(:user_dossiers)).to match([own_dossier]) }
end end
@ -813,14 +813,16 @@ describe Users::DossiersController, type: :controller do
it { expect(assigns(:dossiers_invites)).to match([invite.dossier]) } it { expect(assigns(:dossiers_invites)).to match([invite.dossier]) }
end end
context 'when the user has both' do context 'when the user has dossiers invites, own and traites' do
let!(:procedure) { create(:procedure, :published) }
let!(:own_dossier) { create(:dossier, user: user) } let!(:own_dossier) { create(:dossier, user: user) }
let!(:own_dossier2) { create(:dossier, user: user, state: "accepte", procedure: procedure) }
let!(:invite) { create(:invite, dossier: create(:dossier), user: user) } let!(:invite) { create(:invite, dossier: create(:dossier), user: user) }
context 'and there is no statut param' do context 'and there is no statut param' do
before { get(:index) } before { get(:index) }
it { expect(assigns(:statut)).to eq('mes-dossiers') } it { expect(assigns(:statut)).to eq('en-cours') }
end end
context 'and there is "dossiers-invites" param' do context 'and there is "dossiers-invites" param' do
@ -829,10 +831,24 @@ describe Users::DossiersController, type: :controller do
it { expect(assigns(:statut)).to eq('dossiers-invites') } it { expect(assigns(:statut)).to eq('dossiers-invites') }
end end
context 'and there is "mes-dossiers" param' do context 'and there is "en-cours" param' do
before { get(:index, params: { statut: 'mes-dossiers' }) } before { get(:index, params: { statut: 'en-cours' }) }
it { expect(assigns(:statut)).to eq('mes-dossiers') } it { expect(assigns(:statut)).to eq('en-cours') }
end
context 'and there is "traites" param' do
before { get(:index, params: { statut: 'traites' }) }
it { expect(assigns(:statut)).to eq('traites') }
end
context 'and the traité dossier has been hidden by user' do
before do
own_dossier2.update!(hidden_by_user_at: Time.zone.now)
get(:index, params: { statut: 'traites' })
end
it { expect(assigns(:statut)).to eq('en-cours') }
end end
end end

View file

@ -18,14 +18,4 @@ describe 'users/dossiers/dossier_actions.html.haml', type: :view do
let(:procedure) { create(:procedure, :closed) } let(:procedure) { create(:procedure, :closed) }
it { is_expected.not_to have_link('Commencer un autre dossier') } it { is_expected.not_to have_link('Commencer un autre dossier') }
end end
context 'when there are no actions to display' do
let(:procedure) { create(:procedure, :closed) }
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
let(:user) { create(:user) }
it 'doesnt render the menu at all' do
expect(subject).not_to have_selector('.dropdown')
end
end
end end

View file

@ -2,9 +2,10 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier_brouillon) { create(:dossier, state: Dossier.states.fetch(:brouillon), user: user) } let(:dossier_brouillon) { create(:dossier, state: Dossier.states.fetch(:brouillon), user: user) }
let(:dossier_en_construction) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user) } let(:dossier_en_construction) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user) }
let(:user_dossiers) { [dossier_brouillon, dossier_en_construction] } let(:dossier_termine) { create(:dossier, state: Dossier.states.fetch(:accepte), user: user) }
let(:user_dossiers) { [dossier_brouillon, dossier_en_construction, dossier_termine] }
let(:dossiers_invites) { [] } let(:dossiers_invites) { [] }
let(:statut) { 'mes-dossiers' } let(:statut) { 'en-cours' }
before do before do
allow(view).to receive(:new_demarche_url).and_return('#') allow(view).to receive(:new_demarche_url).and_return('#')
@ -12,6 +13,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
assign(:user_dossiers, Kaminari.paginate_array(user_dossiers).page(1)) assign(:user_dossiers, Kaminari.paginate_array(user_dossiers).page(1))
assign(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).page(1)) assign(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).page(1))
assign(:dossiers_supprimes, Kaminari.paginate_array(user_dossiers).page(1)) assign(:dossiers_supprimes, Kaminari.paginate_array(user_dossiers).page(1))
assign(:dossiers_traites, Kaminari.paginate_array(user_dossiers).page(1))
assign(:dossier_transfers, Kaminari.paginate_array([]).page(1)) assign(:dossier_transfers, Kaminari.paginate_array([]).page(1))
assign(:dossiers_close_to_expiration, Kaminari.paginate_array([]).page(1)) assign(:dossiers_close_to_expiration, Kaminari.paginate_array([]).page(1))
assign(:statut, statut) assign(:statut, statut)
@ -19,7 +21,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
end end
it 'affiche la liste des dossiers' do it 'affiche la liste des dossiers' do
expect(rendered).to have_selector('.dossiers-table tbody tr', count: 2) expect(rendered).to have_selector('.dossiers-table tbody tr', count: 3)
end end
it 'affiche les informations des dossiers' do it 'affiche les informations des dossiers' do
@ -67,8 +69,16 @@ describe 'users/dossiers/index.html.haml', type: :view do
it 'affiche la barre donglets' do it 'affiche la barre donglets' do
expect(rendered).to have_selector('ul.tabs') expect(rendered).to have_selector('ul.tabs')
expect(rendered).to have_selector('ul.tabs li', count: 3) expect(rendered).to have_selector('ul.tabs li', count: 4)
expect(rendered).to have_selector('ul.tabs li.active', count: 1) expect(rendered).to have_selector('ul.tabs li.active', count: 1)
end end
end end
context 'where there is a traite dossier' do
let(:dossiers_traites) { create_list(:dossier, 1) }
it "displays the hide by user at button" do
expect(rendered).to have_text("Supprimer le dossier")
end
end
end end