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_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-12-01 18:05:49 +01:00
|
|
|
let(:dossiers_list_facade) { DossiersListFacades.new gestionnaire, nil }
|
|
|
|
|
|
|
|
let(:new_dossiers_list) { dossiers_list_facade.service.nouveaux }
|
|
|
|
let(:follow_dossiers_list) { dossiers_list_facade.service.suivi }
|
|
|
|
let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state }
|
|
|
|
|
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_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
|
2015-12-24 15:10:20 +01:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
assign :facade_data_view, dossiers_list_facade
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
assign(:new_dossiers, (smart_listing_create :new_dossiers,
|
|
|
|
new_dossiers_list,
|
|
|
|
partial: "backoffice/dossiers/list",
|
|
|
|
array: true))
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
assign(:follow_dossiers, (smart_listing_create :follow_dossiers,
|
|
|
|
follow_dossiers_list,
|
|
|
|
partial: "backoffice/dossiers/list",
|
|
|
|
array: true))
|
2016-11-10 15:57:14 +01:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
assign(:all_state_dossiers, (smart_listing_create :all_state_dossiers,
|
|
|
|
all_state_dossiers_list,
|
|
|
|
partial: "backoffice/dossiers/list",
|
|
|
|
array: true))
|
2015-12-02 18:03:52 +01:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
render
|
2016-08-11 15:27:35 +02:00
|
|
|
end
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
subject { rendered }
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2017-02-28 11:37:37 +01:00
|
|
|
it { is_expected.to have_content('Nouveaux dossiers 1 dossier') }
|
2016-12-01 18:05:49 +01:00
|
|
|
it { is_expected.to have_content('Dossiers suivis 0 dossiers') }
|
2017-02-23 17:54:11 +01:00
|
|
|
it { is_expected.to have_content('Tous les dossiers 7 dossiers') }
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
it { is_expected.to have_content('État') }
|
|
|
|
it { is_expected.to have_content('Libellé procédure') }
|
|
|
|
it { is_expected.to have_content('Raison sociale') }
|
|
|
|
it { is_expected.to have_content('Mise à jour le') }
|
2016-07-19 17:18:41 +02:00
|
|
|
|
2016-12-01 18:05:49 +01:00
|
|
|
it { is_expected.to have_content('plap') }
|
|
|
|
it { is_expected.to have_content('plep') }
|
|
|
|
it { is_expected.to have_content('plup') }
|
|
|
|
it { is_expected.to have_content('plyp') }
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|