2015-08-25 16:33:55 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-24 11:37:18 +02:00
|
|
|
describe 'users/recapitulatif/show.html.haml', type: :view do
|
2016-01-18 17:18:04 +01:00
|
|
|
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) }
|
2015-09-24 11:37:18 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'draft' }
|
2015-09-24 11:37:18 +02:00
|
|
|
|
2015-08-25 16:33:55 +02:00
|
|
|
before do
|
2015-12-24 15:10:20 +01:00
|
|
|
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
|
2015-08-25 16:33:55 +02:00
|
|
|
end
|
2015-09-24 12:04:44 +02:00
|
|
|
|
2015-09-24 11:37:18 +02:00
|
|
|
context 'sur la rendered recapitulative' do
|
2015-09-24 16:51:14 +02:00
|
|
|
context 'test de composition de la page' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
2015-09-24 12:04:44 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
it 'la section infos dossier est présente' do
|
|
|
|
expect(rendered).to have_selector('#infos_dossier')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le flux de commentaire est présent' do
|
|
|
|
expect(rendered).to have_selector('#commentaires_flux')
|
|
|
|
end
|
2015-09-24 12:04:44 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
it 'le numéro de dossier est présent' do
|
|
|
|
expect(rendered).to have_selector('#dossier_id')
|
|
|
|
expect(rendered).to have_content(dossier_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'les liens de modifications' do
|
|
|
|
context 'lien description' do
|
|
|
|
it 'le lien vers description est présent' do
|
|
|
|
expect(rendered).to have_css('#maj_infos')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le lien vers description est correct' do
|
2015-11-19 16:47:56 +01:00
|
|
|
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'lien carte' do
|
|
|
|
it 'le lien vers carte est présent' do
|
|
|
|
expect(rendered).to have_css('#maj_carte')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le lien vers description est correct' do
|
|
|
|
expect(rendered).to have_selector("a[id=maj_carte][href='/users/dossiers/#{dossier_id}/carte']")
|
2015-09-24 16:51:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-09-24 11:37:18 +02:00
|
|
|
end
|
2015-09-24 12:04:44 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
context 'buttons to change dossier state' do
|
2015-11-02 15:31:15 +01:00
|
|
|
context 'when dossier state is 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
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content('Soumis') }
|
|
|
|
end
|
2015-09-24 11:37:18 +02:00
|
|
|
|
2015-11-02 11:33:00 +01:00
|
|
|
context 'when dossier state is 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
|
2015-09-24 11:37:18 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
it { expect(rendered).to have_content('Répondu') }
|
|
|
|
end
|
2015-09-24 11:37:18 +02:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
context 'when dossier state is updated' 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') }
|
|
|
|
end
|
|
|
|
|
2015-11-02 11:45:52 +01:00
|
|
|
context 'when dossier state is 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
|
|
|
|
|
|
|
|
it 'button Déposer mon dossier est present' do
|
2015-11-27 13:56:54 +01:00
|
|
|
expect(rendered).to have_css('#validate_button')
|
2015-09-24 16:51:14 +02:00
|
|
|
expect(rendered).to have_content('Déposer mon dossier')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'button Editer mon dossier n\'est plus present' do
|
|
|
|
expect(rendered).not_to have_css('#maj_infos')
|
|
|
|
expect(rendered).not_to have_content('Editer mon dossier')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-02 15:46:43 +01:00
|
|
|
context 'when dossier state is 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é') }
|
|
|
|
|
|
|
|
it 'button Editer mon dossier n\'est plus present' do
|
|
|
|
expect(rendered).not_to have_css('#maj_infos')
|
|
|
|
expect(rendered).not_to have_content('Editer mon dossier')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier state is traité' do
|
2015-12-24 15:10:20 +01:00
|
|
|
let(:state) { 'closed' }
|
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
it { expect(rendered).to have_content('Traité') }
|
|
|
|
|
|
|
|
it 'button Editer mon dossier n\'est plus present' do
|
|
|
|
expect(rendered).not_to have_css('#maj_infos')
|
|
|
|
expect(rendered).not_to have_content('Editer mon dossier')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 16:33:55 +02:00
|
|
|
end
|