2015-09-24 16:51:14 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'backoffice/dossiers/show.html.haml', type: :view do
|
2016-02-04 14:08:35 +01:00
|
|
|
let!(:dossier) { create(:dossier, :with_entreprise, state: state) }
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'draft' }
|
2015-09-24 16:51:14 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
2015-09-24 16:51:14 +02:00
|
|
|
|
|
|
|
before do
|
2015-12-24 15:10:20 +01:00
|
|
|
sign_in gestionnaire
|
|
|
|
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
|
2016-02-08 18:16:18 +01:00
|
|
|
context 'on the dossier gestionnaire page' do
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
2016-03-22 17:36:36 +01:00
|
|
|
|
|
|
|
it 'button Modifier les document est present' do
|
|
|
|
expect(rendered).not_to have_content('Modifier les documents')
|
|
|
|
expect(rendered).not_to have_css('#UploadPJmodal')
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
it 'enterprise informations are present' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to have_selector('#infos_entreprise')
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
it 'dossier informations are present' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to have_selector('#infos_dossier')
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
it 'dossier number is present' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to have_selector('#dossier_id')
|
|
|
|
expect(rendered).to have_content(dossier_id)
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
context 'edit link are present' do
|
|
|
|
it 'edit carto' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
it 'edit description' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to_not have_selector('a[id=modif_description]')
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
it 'Editer mon dossier button doesnt present' do
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to_not have_css('#maj_infos')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
context 'dossier state changements' do
|
2015-11-02 15:31:15 +01:00
|
|
|
context 'when dossier have state initiated' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'initiated' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it { expect(rendered).to have_content('Nouveau') }
|
2015-09-24 16:51:14 +02:00
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is present' do
|
|
|
|
expect(rendered).to have_css('.action_button')
|
|
|
|
expect(rendered).to have_content('Déclarer complet')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 11:33:00 +01:00
|
|
|
context 'when dossier have state replied' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'replied' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Répondu') }
|
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is present' do
|
|
|
|
expect(rendered).to have_css('.action_button')
|
|
|
|
expect(rendered).to have_content('Déclarer complet')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier have state update' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'updated' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Mis à jour') }
|
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is present' do
|
|
|
|
expect(rendered).to have_css('.action_button')
|
|
|
|
expect(rendered).to have_content('Déclarer complet')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 11:45:52 +01:00
|
|
|
context 'when dossier have state validated' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'validated' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
2016-08-11 15:27:35 +02:00
|
|
|
it { expect(rendered).to have_content('Figé') }
|
2015-09-24 16:51:14 +02:00
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is not present' do
|
|
|
|
expect(rendered).not_to have_css('.action_button')
|
|
|
|
expect(rendered).not_to have_content('Déclarer complet')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 15:46:43 +01:00
|
|
|
context 'when dossier have state submitted' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'submitted' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Déposé') }
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
it 'button notifier de la bonne réception is present' do
|
2016-10-19 11:23:34 +02:00
|
|
|
expect(rendered).to have_css('.action_button')
|
2016-08-25 15:21:25 +02:00
|
|
|
expect(rendered).to have_content('Notifier de la bonne réception')
|
2015-10-09 12:05:07 +02:00
|
|
|
end
|
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is not present' do
|
2016-08-25 15:21:25 +02:00
|
|
|
expect(rendered).not_to have_content('Accepter le dossier')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
context 'when dossier have state received' do
|
|
|
|
let(:state) { 'received' }
|
2015-12-24 15:10:20 +01:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
it { expect(rendered).to have_content('Reçu') }
|
2016-08-11 15:27:35 +02:00
|
|
|
|
2016-08-25 17:46:26 +02:00
|
|
|
it 'button accepter / refuser / classer sans suite are present' do
|
|
|
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
|
|
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
|
|
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
2016-08-11 15:27:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
context 'when dossier have state closed' do
|
|
|
|
let(:state) { 'closed' }
|
2016-08-11 15:27:35 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
it { expect(rendered).to have_content('Accepté') }
|
2016-08-11 15:27:35 +02:00
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
it 'button Accepter le dossier is not present' do
|
2016-08-25 17:46:26 +02:00
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
2016-08-11 15:27:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier have state without_continuation' do
|
|
|
|
let(:state) { 'without_continuation' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Sans suite') }
|
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is not present' do
|
2016-08-25 17:46:26 +02:00
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
2016-08-11 15:27:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier have state refused' do
|
|
|
|
let(:state) { 'refused' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Refusé') }
|
2015-09-24 16:51:14 +02:00
|
|
|
|
2016-10-19 11:23:34 +02:00
|
|
|
it 'button Déclarer complet is not present' do
|
2016-08-25 17:46:26 +02:00
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
|
|
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 18:56:41 +01:00
|
|
|
#TODO réactiver
|
|
|
|
# context 'la liste des pièces justificatives est présente' do
|
|
|
|
# context 'Attestation MSA' do
|
|
|
|
# let(:id_piece_justificative) { 93 }
|
|
|
|
#
|
|
|
|
# it 'la ligne de la pièce justificative est présente' do
|
|
|
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# it 'le bouton "Récupérer" est présent' do
|
|
|
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_selector("a[href='']")
|
|
|
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# context 'Attestation RDI' do
|
|
|
|
# let(:id_piece_justificative) { 103 }
|
|
|
|
#
|
|
|
|
# it 'la ligne de la pièce justificative est présente' do
|
|
|
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# it 'le libelle "Pièce manquante" est présent' do
|
|
|
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# context 'Devis' do
|
|
|
|
# let(:id_piece_justificative) { 388 }
|
|
|
|
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
|
|
|
#
|
|
|
|
# before do
|
|
|
|
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
|
|
|
|
# piece_justificative.content = content
|
|
|
|
# piece_justificative.save!
|
|
|
|
# visit "/admin/dossiers/#{dossier_id}"
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# it 'la ligne de la pièce justificative est présente' do
|
|
|
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# it 'le libelle "Consulter" est présent' do
|
|
|
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}] a")[:href]).to have_content('piece_justificative_388.pdf')
|
|
|
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|