2015-09-28 10:32:41 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'users/description/show.html.haml', type: :view do
|
|
|
|
let(:user) { create(:user) }
|
2016-02-02 18:37:38 +01:00
|
|
|
let(:cerfa_flag) { true }
|
2016-06-22 11:25:41 +02:00
|
|
|
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: cerfa_flag) }
|
2016-02-02 18:37:38 +01:00
|
|
|
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
2015-09-28 10:32:41 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
|
|
|
|
|
|
|
before do
|
2016-06-06 17:40:32 +02:00
|
|
|
sign_in user
|
2015-09-28 10:32:41 +02:00
|
|
|
assign(:dossier, dossier)
|
|
|
|
assign(:procedure, dossier.procedure)
|
2015-11-04 11:14:07 +01:00
|
|
|
assign(:champs, dossier.ordered_champs)
|
2015-09-28 10:32:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'tous les attributs sont présents sur la page' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
|
|
|
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Charger votre CERFA (PDF)' do
|
|
|
|
expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Lien CERFA' do
|
|
|
|
expect(rendered).to have_selector('#lien_cerfa')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'si la page précédente n\'est pas recapitulatif' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
it 'le bouton "Terminer" est présent' do
|
|
|
|
expect(rendered).to have_selector('#suivant')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'si la page précédente est recapitularif' do
|
|
|
|
before do
|
2017-12-14 15:51:45 +01:00
|
|
|
dossier.en_construction!
|
2015-09-28 10:32:41 +02:00
|
|
|
dossier.reload
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le bouton "Terminer" n\'est pas présent' do
|
|
|
|
expect(rendered).to_not have_selector('#suivant')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le bouton "Modification terminé" est présent' do
|
|
|
|
expect(rendered).to have_selector('#modification_terminee')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'le lien de retour au récapitulatif est présent' do
|
|
|
|
expect(rendered).to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-04 11:14:07 +01:00
|
|
|
context 'Champs' do
|
|
|
|
let(:champs) { dossier.champs }
|
2016-06-22 11:25:41 +02:00
|
|
|
let(:types_de_champ) { procedure.types_de_champ.where(type_champ: 'datetime').first }
|
|
|
|
let(:champ_datetime) { champs.where(type_de_champ_id: types_de_champ.id).first }
|
2015-11-04 11:14:07 +01:00
|
|
|
|
|
|
|
before do
|
2016-06-22 11:25:41 +02:00
|
|
|
champ_datetime.value = "22/06/2016 12:05"
|
|
|
|
champ_datetime.save
|
2015-11-04 11:14:07 +01:00
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'first champs' do
|
|
|
|
subject { dossier.champs.first }
|
|
|
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'last champs' do
|
|
|
|
subject { dossier.champs.last }
|
|
|
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
|
|
|
end
|
2016-06-22 11:25:41 +02:00
|
|
|
|
|
|
|
describe 'datetime value is correctly setup when is not nil' do
|
|
|
|
it { expect(rendered).to have_css("input[type='datetime'][id='champs_#{champ_datetime.id}'][value='22/06/2016']") }
|
|
|
|
it { expect(rendered).to have_css("option[value='12'][selected='selected']")}
|
|
|
|
it { expect(rendered).to have_css("option[value='05'][selected='selected']")}
|
|
|
|
end
|
2015-11-04 11:14:07 +01:00
|
|
|
end
|
|
|
|
|
2015-09-28 10:32:41 +02:00
|
|
|
context 'Pièces justificatives' do
|
|
|
|
let(:all_type_pj_procedure_id) { dossier.procedure.type_de_piece_justificative_ids }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'la liste des pièces justificatives a envoyé est affichée' do
|
|
|
|
it 'RIB' do
|
|
|
|
expect(rendered).to have_css("#piece_justificative_#{all_type_pj_procedure_id[0]}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-02-02 18:37:38 +01:00
|
|
|
|
|
|
|
context 'Envoi des CERFA désactivé' do
|
|
|
|
let!(:cerfa_flag) { false }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(rendered).to_not have_css("#cerfa_flag") }
|
|
|
|
it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') }
|
|
|
|
end
|
2016-02-08 19:52:07 +01:00
|
|
|
|
|
|
|
describe 'display title Documents administratifs' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:procedure) { create :procedure, lien_demarche: '' }
|
|
|
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
|
|
|
|
|
|
|
context 'when dossier not have cerfa, piece justificative and demarche link' do
|
|
|
|
it { expect(rendered).not_to have_content 'Documents administratifs' }
|
|
|
|
end
|
|
|
|
end
|
2015-09-28 10:32:41 +02:00
|
|
|
end
|