2015-12-02 16:52:09 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'users/dossiers/index.html.haml', type: :view do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate }
|
2017-12-14 15:53:02 +01:00
|
|
|
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, user: user, state: 'en_instruction').decorate }
|
2017-12-04 18:00:12 +01:00
|
|
|
let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, user: user, state: 'accepte').decorate }
|
2017-12-04 18:15:40 +01:00
|
|
|
let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, user: user, state: 'refuse').decorate }
|
2017-12-04 20:23:57 +01:00
|
|
|
let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, user: user, state: 'sans_suite').decorate }
|
2017-12-14 15:51:45 +01:00
|
|
|
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate }
|
2016-07-19 16:10:50 +02:00
|
|
|
|
|
|
|
before do
|
2016-08-22 16:10:48 +02:00
|
|
|
create :invite, dossier: decorate_dossier_invite, user: user
|
2016-07-19 16:10:50 +02:00
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
shared_examples 'check_tab_content' do
|
2015-12-02 16:52:09 +01:00
|
|
|
before do
|
|
|
|
sign_in user
|
|
|
|
|
2016-01-11 14:10:41 +01:00
|
|
|
assign(:dossiers, (smart_listing_create :dossiers,
|
2017-06-12 13:49:51 +02:00
|
|
|
dossiers_to_display,
|
|
|
|
partial: "users/dossiers/list",
|
|
|
|
array: true))
|
2015-12-02 16:52:09 +01:00
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { rendered }
|
|
|
|
|
2018-06-25 13:52:23 +02:00
|
|
|
it 'displays the total count' do
|
|
|
|
expect(dossiers_to_display.count).to eq total_dossiers
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
|
2018-06-25 13:52:23 +02:00
|
|
|
it 'displays data in columns' do
|
|
|
|
expect(rendered).to have_content(decorate_dossier_at_check.id)
|
|
|
|
expect(rendered).to have_content(decorate_dossier_at_check.procedure.libelle)
|
|
|
|
expect(rendered).to have_content(decorate_dossier_at_check.display_state)
|
|
|
|
expect(rendered).to have_content(decorate_dossier_at_check.last_update)
|
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
|
2016-10-19 17:25:24 +02:00
|
|
|
describe 'on tab en construction' do
|
2017-09-22 10:28:16 +02:00
|
|
|
let(:total_dossiers) { 1 }
|
2016-10-19 17:25:24 +02:00
|
|
|
let(:active_class) { '.active .text-danger' }
|
2017-05-26 18:59:21 +02:00
|
|
|
let(:dossiers_to_display) { user.dossiers.state_en_construction }
|
2016-10-19 17:25:24 +02:00
|
|
|
let(:liste) { 'a_traiter' }
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
2017-12-14 15:51:45 +01:00
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_en_construction }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:57:51 +02:00
|
|
|
describe 'on tab etude en examen' do
|
2017-02-23 17:54:11 +01:00
|
|
|
let(:total_dossiers) { 1 }
|
2016-08-22 16:10:48 +02:00
|
|
|
let(:active_class) { '.active .text-default' }
|
2017-05-26 18:59:21 +02:00
|
|
|
let(:dossiers_to_display) { user.dossiers.state_en_instruction }
|
2016-08-22 16:10:48 +02:00
|
|
|
let(:liste) { 'en_instruction' }
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
2017-12-14 15:53:02 +01:00
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_en_instruction }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
describe 'on tab etude termine' do
|
|
|
|
let(:total_dossiers) { 3 }
|
|
|
|
let(:active_class) { '.active .text-success' }
|
2017-05-26 18:59:21 +02:00
|
|
|
let(:dossiers_to_display) { user.dossiers.state_termine }
|
2016-08-22 16:10:48 +02:00
|
|
|
let(:liste) { 'termine' }
|
|
|
|
|
|
|
|
it_behaves_like 'check_tab_content' do
|
2017-12-04 18:00:12 +01:00
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_accepte }
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
2017-12-04 18:15:40 +01:00
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_refuse }
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
2017-12-04 20:23:57 +01:00
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_sans_suite }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'on tab etude invite' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-warning' }
|
|
|
|
let(:dossiers_to_display) { user.invites }
|
|
|
|
let(:liste) { 'invite' }
|
2015-12-02 16:52:09 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_invite }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|