2015-12-02 18:03:52 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
2016-05-20 15:39:17 +02:00
|
|
|
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
2015-12-02 18:03:52 +01:00
|
|
|
|
|
|
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
2016-03-14 16:49:12 +01:00
|
|
|
|
2016-07-19 16:10:50 +02:00
|
|
|
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate }
|
|
|
|
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate }
|
2016-08-11 15:27:35 +02:00
|
|
|
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated').decorate }
|
|
|
|
let!(:decorate_dossier_validated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'validated').decorate }
|
|
|
|
let!(:decorate_dossier_submitted) { create(:dossier, :with_entreprise, procedure: procedure, state: 'submitted').decorate }
|
|
|
|
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate }
|
2016-07-19 16:10:50 +02:00
|
|
|
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate }
|
2016-08-11 15:27:35 +02:00
|
|
|
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate }
|
|
|
|
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'without_continuation').decorate }
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-05-20 15:39:17 +02:00
|
|
|
before do
|
2016-08-11 15:27:35 +02:00
|
|
|
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap')
|
|
|
|
decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep')
|
|
|
|
decorate_dossier_validated.entreprise.update_column(:raison_sociale, 'plip')
|
|
|
|
decorate_dossier_submitted.entreprise.update_column(:raison_sociale, 'plop')
|
|
|
|
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
|
|
|
|
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
|
|
|
|
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
|
|
|
|
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
|
2016-07-19 16:10:50 +02:00
|
|
|
|
2016-08-01 18:10:32 +02:00
|
|
|
create :preference_list_dossier,
|
|
|
|
gestionnaire: gestionnaire,
|
2016-09-27 17:53:46 +02:00
|
|
|
table: nil,
|
2016-08-01 18:10:32 +02:00
|
|
|
attr: 'state',
|
|
|
|
attr_decorate: 'display_state'
|
|
|
|
|
|
|
|
create :preference_list_dossier,
|
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: 'procedure',
|
|
|
|
attr: 'libelle',
|
|
|
|
attr_decorate: 'libelle'
|
|
|
|
|
|
|
|
create :preference_list_dossier,
|
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: 'entreprise',
|
|
|
|
attr: 'raison_sociale',
|
|
|
|
attr_decorate: 'raison_sociale'
|
|
|
|
|
|
|
|
create :preference_list_dossier,
|
|
|
|
gestionnaire: gestionnaire,
|
2016-09-27 17:53:46 +02:00
|
|
|
table: nil,
|
2016-08-01 18:10:32 +02:00
|
|
|
attr: 'last_update',
|
|
|
|
attr_decorate: 'last_update'
|
|
|
|
|
2016-05-20 15:39:17 +02:00
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
2016-07-19 16:10:50 +02:00
|
|
|
sign_in gestionnaire
|
2016-05-20 15:39:17 +02:00
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
shared_examples 'check_tab_content' do
|
2015-12-02 18:03:52 +01:00
|
|
|
before do
|
2016-08-11 15:27:35 +02:00
|
|
|
assign :dossiers_list_facade, (DossiersListFacades.new gestionnaire, liste)
|
2016-01-11 14:10:41 +01:00
|
|
|
assign(:dossiers, (smart_listing_create :dossiers,
|
2016-08-11 15:27:35 +02:00
|
|
|
dossiers_to_display,
|
2016-01-11 14:10:41 +01:00
|
|
|
partial: "backoffice/dossiers/list",
|
|
|
|
array: true))
|
2015-12-02 18:03:52 +01:00
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { rendered }
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'pref list column' do
|
|
|
|
it { is_expected.to have_css('#backoffice_index') }
|
|
|
|
it { is_expected.to have_content(procedure.libelle) }
|
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.entreprise.raison_sociale) }
|
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
|
|
|
|
it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to have_css("#suivre_dossier_#{dossiers_to_display.first.id}") }
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it { expect(dossiers_to_display.count).to eq total_dossiers }
|
2016-07-18 18:24:29 +02:00
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
describe 'active tab' do
|
2016-08-11 15:27:35 +02:00
|
|
|
it { is_expected.to have_selector(active_class) }
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'on tab nouveaux' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-info' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.nouveaux }
|
|
|
|
let(:liste) { 'nouveaux' }
|
2015-12-24 15:10:20 +01:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
2016-08-11 15:27:35 +02:00
|
|
|
end
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'on tab a_traiter' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-danger' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.waiting_for_gestionnaire }
|
|
|
|
let(:liste) { 'a_traiter' }
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_updated }
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'on tab en_attente' do
|
|
|
|
let(:total_dossiers) { 2 }
|
|
|
|
let(:active_class) { '.active .text-default' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.waiting_for_user }
|
|
|
|
let(:liste) { 'en_attente' }
|
|
|
|
|
|
|
|
describe 'for state replied' do
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_replied }
|
|
|
|
end
|
2016-07-19 17:18:41 +02:00
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'for state validated' do
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_validated }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'on tab deposes' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-purple' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.deposes }
|
|
|
|
let(:liste) { 'deposes' }
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_submitted }
|
|
|
|
end
|
|
|
|
end
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'on tab a_instruire' do
|
|
|
|
let(:total_dossiers) { 1 }
|
|
|
|
let(:active_class) { '.active .text-warning' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.a_instruire }
|
|
|
|
let(:liste) { 'a_instruire' }
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_received }
|
2016-07-19 17:18:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
describe 'on tab termine' do
|
2016-08-11 15:27:35 +02:00
|
|
|
let(:total_dossiers) { 3 }
|
|
|
|
let(:active_class) { '.active .text-success' }
|
|
|
|
let(:dossiers_to_display) { gestionnaire.dossiers.termine }
|
|
|
|
let(:liste) { 'termine' }
|
|
|
|
|
|
|
|
describe 'for state closed' do
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_closed }
|
|
|
|
end
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'for state refused' do
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_refused }
|
|
|
|
end
|
|
|
|
end
|
2016-07-18 18:24:29 +02:00
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
describe 'for state without_continuation' do
|
|
|
|
it_behaves_like 'check_tab_content' do
|
|
|
|
let(:decorate_dossier_at_check) { decorate_dossier_without_continuation }
|
|
|
|
end
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|