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
|
|
|
|
2017-07-18 15:26:33 +02:00
|
|
|
let!(:procedure) { create(:procedure, :published, 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 }
|
2016-08-11 15:27:35 +02:00
|
|
|
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_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,
|
2017-06-12 13:49:51 +02:00
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: nil,
|
|
|
|
attr: 'state',
|
|
|
|
attr_decorate: 'display_state'
|
2016-08-01 18:10:32 +02:00
|
|
|
|
|
|
|
create :preference_list_dossier,
|
2017-06-12 13:49:51 +02:00
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: 'procedure',
|
|
|
|
attr: 'libelle',
|
|
|
|
attr_decorate: 'libelle'
|
2016-08-01 18:10:32 +02:00
|
|
|
|
|
|
|
create :preference_list_dossier,
|
2017-06-12 13:49:51 +02:00
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: 'entreprise',
|
|
|
|
attr: 'raison_sociale',
|
|
|
|
attr_decorate: 'raison_sociale'
|
2016-08-01 18:10:32 +02:00
|
|
|
|
|
|
|
create :preference_list_dossier,
|
2017-06-12 13:49:51 +02:00
|
|
|
gestionnaire: gestionnaire,
|
|
|
|
table: nil,
|
|
|
|
attr: 'last_update',
|
|
|
|
attr_decorate: 'last_update'
|
2016-08-01 18:10:32 +02:00
|
|
|
|
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,
|
2017-06-12 13:49:51 +02:00
|
|
|
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,
|
2017-06-12 13:49:51 +02:00
|
|
|
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,
|
2017-06-12 13:49:51 +02:00
|
|
|
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-09-22 10:28:16 +02:00
|
|
|
it { is_expected.to have_content('Tous les dossiers 5 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('plup') }
|
|
|
|
it { is_expected.to have_content('plyp') }
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|