2015-12-02 16:52:09 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'users/dossiers/index.html.haml', type: :view do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate }
|
|
|
|
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
|
|
|
|
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate }
|
|
|
|
let!(:decorate_dossier_validated) { create(:dossier, :with_entreprise, user: user, state: 'validated').decorate }
|
|
|
|
let!(:decorate_dossier_submitted) { create(:dossier, :with_entreprise, user: user, state: 'submitted').decorate }
|
|
|
|
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate }
|
|
|
|
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
|
|
|
|
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate }
|
|
|
|
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, user: user, state: 'without_continuation').decorate }
|
|
|
|
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').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-08-22 16:10:48 +02:00
|
|
|
assign :dossiers_list_facade, (DossiersListFacades.new user, liste)
|
2016-01-11 14:10:41 +01:00
|
|
|
assign(:dossiers, (smart_listing_create :dossiers,
|
2016-08-22 16:10:48 +02:00
|
|
|
dossiers_to_display,
|
2016-01-11 14:10:41 +01:00
|
|
|
partial: "users/dossiers/list",
|
|
|
|
array: true))
|
2015-12-02 16:52:09 +01:00
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { rendered }
|
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
describe 'columns' do
|
2016-08-30 11:18:43 +02:00
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.id) }
|
2016-08-22 16:10:48 +02:00
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.procedure.libelle) }
|
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
|
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
it { expect(dossiers_to_display.count).to eq total_dossiers }
|
2016-01-19 17:19:38 +01:00
|
|
|
|
2016-08-22 16:10:48 +02:00
|
|
|
describe 'active tab' do
|
|
|
|
it { is_expected.to have_selector(active_class) }
|
2016-01-19 17:19:38 +01:00
|
|
|
end
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
|
2016-10-19 17:25:24 +02:00
|
|
|
describe 'on tab en construction' do
|
|
|
|
let(:total_dossiers) { 3 }
|
|
|
|
let(:active_class) { '.active .text-danger' }
|
|
|
|
let(:dossiers_to_display) { user.dossiers.en_construction }
|
|
|
|
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
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
2016-08-22 16:10:48 +02:00
|
|
|
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_replied }
|
|
|
|
end
|
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_updated }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
2016-08-22 16:10:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'on tab etude a deposer' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-purple' }
|
|
|
|
let(:dossiers_to_display) { user.dossiers.valides }
|
|
|
|
let(:liste) { 'valides' }
|
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_validated }
|
2015-12-02 16:52:09 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-14 16:57:51 +02:00
|
|
|
describe 'on tab etude en examen' do
|
2016-08-22 16:10:48 +02:00
|
|
|
let(:total_dossiers) { 2 }
|
|
|
|
let(:active_class) { '.active .text-default' }
|
|
|
|
let(:dossiers_to_display) { user.dossiers.en_instruction }
|
|
|
|
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
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_submitted }
|
|
|
|
end
|
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_received }
|
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' }
|
|
|
|
let(:dossiers_to_display) { user.dossiers.termine }
|
|
|
|
let(:liste) { 'termine' }
|
|
|
|
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_closed }
|
|
|
|
end
|
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_refused }
|
|
|
|
end
|
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_without_continuation }
|
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
|
|
|
|
end
|