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

132 lines
3.6 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_user, :with_entreprise, :with_procedure) }
let(:dossier_id) { dossier.id }
2015-08-25 16:33:55 +02:00
before do
assign(:dossier, dossier.decorate)
assign(:procedure, dossier.procedure)
2015-08-25 16:33:55 +02:00
assign(:commentaires, dossier.commentaires)
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_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
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
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description?back_url=recapitulatif']")
end
end
end
end
2015-09-24 12:04:44 +02:00
context 'buttons to change dossier state' do
context 'when dossier state is draft' do
before do
dossier.draft!
render
end
2015-09-24 12:04:44 +02:00
it 'button Soumettre mon dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Soumettre mon dossier')
end
end
2015-09-24 12:04:44 +02:00
context 'when dossier state is submitted' do
before do
dossier.submitted!
render
end
it { expect(rendered).to have_content('Soumis') }
end
context 'when dossier state is replied' do
before do
dossier.replied!
render
end
#TODO gestionnaire test
it { expect(rendered).to have_content('Répondu') }
end
context 'when dossier state is updated' do
before do
dossier.updated!
render
end
it { expect(rendered).to have_content('Mis à jour') }
end
context 'when dossier state is confirmed' do
before do
dossier.confirmed!
render
end
it 'button Déposer mon dossier est present' do
expect(rendered).to have_css('#action_button')
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
context 'when dossier state is deposited' do
before do
dossier.deposited!
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
before do
dossier.processed!
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