tests
This commit is contained in:
parent
eaac293da3
commit
06540c1b93
3 changed files with 37 additions and 21 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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 'doesn’t render the menu at all' do
|
|
||||||
expect(subject).not_to have_selector('.dropdown')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -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 d’onglets' do
|
it 'affiche la barre d’onglets' 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
|
||||||
|
|
Loading…
Reference in a new issue