This commit is contained in:
kara Diaby 2021-11-10 17:36:42 +01:00 committed by Kara Diaby
parent eaac293da3
commit 06540c1b93
3 changed files with 37 additions and 21 deletions

View file

@ -793,14 +793,14 @@ describe Users::DossiersController, type: :controller do
context 'when the user does not have any dossiers' do
before { get(:index) }
it { expect(assigns(:statut)).to eq('mes-dossiers') }
it { expect(assigns(:statut)).to eq('en-cours') }
end
context 'when the user only have its own dossiers' do
let!(:own_dossier) { create(:dossier, user: user) }
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]) }
end
@ -813,14 +813,16 @@ describe Users::DossiersController, type: :controller do
it { expect(assigns(:dossiers_invites)).to match([invite.dossier]) }
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_dossier2) { create(:dossier, user: user, state: "accepte", procedure: procedure) }
let!(:invite) { create(:invite, dossier: create(:dossier), user: user) }
context 'and there is no statut param' do
before { get(:index) }
it { expect(assigns(:statut)).to eq('mes-dossiers') }
it { expect(assigns(:statut)).to eq('en-cours') }
end
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') }
end
context 'and there is "mes-dossiers" param' do
before { get(:index, params: { statut: 'mes-dossiers' }) }
context 'and there is "en-cours" param' do
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

View file

@ -18,14 +18,4 @@ describe 'users/dossiers/dossier_actions.html.haml', type: :view do
let(:procedure) { create(:procedure, :closed) }
it { is_expected.not_to have_link('Commencer un autre dossier') }
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

View file

@ -2,9 +2,10 @@ describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(: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(: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(:statut) { 'mes-dossiers' }
let(:statut) { 'en-cours' }
before do
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(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).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(:dossiers_close_to_expiration, Kaminari.paginate_array([]).page(1))
assign(:statut, statut)
@ -19,7 +21,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
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
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
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)
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