demarches-normaliennes/spec/views/users/recapitulatif/show.html.haml_spec.rb

135 lines
4 KiB
Ruby
Raw Normal View History

2015-08-25 16:33:55 +02:00
require 'spec_helper'
describe 'users/recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true, individual_with_siret: true)) }
let(:dossier_id) { dossier.id }
2017-12-04 16:17:15 +01:00
let(:state) { 'brouillon' }
2015-08-25 16:33:55 +02:00
before do
sign_in dossier.user
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
context 'sur la rendered recapitulative' do
context 'test de composition de la page' do
before do
render
end
2015-09-24 12:04:44 +02:00
it 'la section infos dossier est présente' do
expect(rendered).to have_selector('#infos-dossiers')
2016-12-14 18:41:33 +01:00
end
it 'le flux de commentaire est présent' do
expect(rendered).to have_selector('#messages')
end
2015-09-24 12:04:44 +02:00
describe '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
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description']")
end
end
2016-12-14 18:41:33 +01:00
context 'lien carte' do
it 'le lien vers carte est présent' do
expect(rendered).to have_css('#maj_pj')
end
end
2016-12-14 18:41:33 +01:00
context 'lien carte' do
it 'le lien vers le renseignement un SIRET est présent' do
expect(rendered).to have_css('#add_siret')
end
end
2016-12-14 18:41:33 +01:00
context 'lien carte' do
it 'le lien vers carte est présent' do
expect(rendered).to have_css('#maj_carte')
end
2016-12-14 18:41:33 +01:00
it 'le lien vers description est correct' do
expect(rendered).to have_selector("a[id=maj_carte][href='/users/dossiers/#{dossier_id}/carte']")
end
end
end
2016-12-14 18:41:33 +01:00
end
context 'when dossier state is en_construction' do
let(:state) { 'en_construction' }
2016-12-14 18:41:33 +01:00
before do
render
end
2016-12-14 18:41:33 +01:00
it 'button Modifier les document est present' do
expect(rendered).to have_content('Modifier les documents')
expect(rendered).to have_css('#upload-pj-modal')
end
end
context 'when invite is logged' do
context 'when invite is by Gestionnaire' do
let!(:invite_user) { create(:user, email: 'invite@octo.com') }
before do
create(:invite) { create(:invite, email: invite_user.email, user: invite_user, dossier: dossier) }
sign_out dossier.user
sign_in invite_user
render
end
describe 'les liens de modifications' do
it 'describe link is not present' do
expect(rendered).not_to have_css('#maj_infos')
end
it 'map link is not present' do
expect(rendered).not_to have_css('#maj_carte')
end
it 'PJ link is not present' do
expect(rendered).not_to have_css('#maj_pj')
end
it 'archive link is not present' do
expect(rendered).not_to have_content('Archiver')
end
end
end
context 'invite is by User' do
let!(:invite_user) { create(:user, email: 'invite@octo.com') }
before do
create(:invite) { create(:invite, email: invite_user.email, user: invite_user, dossier: dossier, type: 'InviteUser') }
sign_out dossier.user
sign_in invite_user
render
end
describe 'les liens de modifications' do
it 'describe link is not present' do
expect(rendered).to have_css('#maj_infos')
end
2016-12-14 18:41:33 +01:00
it 'map link is present' do
expect(rendered).to have_css('#maj_carte')
end
it 'PJ link is present' do
expect(rendered).to have_css('#maj_pj')
end
it 'archive link is present' do
expect(rendered).not_to have_content('Archiver')
end
end
end
end
end
2015-08-25 16:33:55 +02:00
end