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 }
|
|
|
|
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: cerfa_flag) }
|
|
|
|
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 'Nom du projet' do
|
|
|
|
expect(rendered).to have_selector('input[id=nom_projet][name=nom_projet]')
|
|
|
|
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
|
2015-11-02 15:31:15 +01:00
|
|
|
dossier.initiated!
|
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
|
|
|
|
|
|
|
|
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
|
|
|
|
let!(:dossier) do
|
2016-02-04 14:08:35 +01:00
|
|
|
create(:dossier,
|
2015-09-28 10:32:41 +02:00
|
|
|
nom_projet: 'Projet de test',
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Nom du projet' do
|
|
|
|
expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-04 11:14:07 +01:00
|
|
|
context 'Champs' do
|
|
|
|
let(:champs) { dossier.champs }
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'first champs' do
|
|
|
|
subject { dossier.champs.first }
|
2015-11-17 10:23:05 +01:00
|
|
|
it { expect(rendered).to have_css(".type_champ-#{subject.type_champ}") }
|
2015-11-04 11:14:07 +01:00
|
|
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'last champs' do
|
|
|
|
subject { dossier.champs.last }
|
2015-11-17 10:23:05 +01:00
|
|
|
it { expect(rendered).to have_css(".type_champ-#{subject.type_champ}") }
|
2015-11-04 11:14:07 +01:00
|
|
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
|
|
|
end
|
|
|
|
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
|
|
|
|
|
|
|
|
context 'la liste des pièces récupérées automatiquement est signaliée' do
|
|
|
|
it 'Attestation MSA' do
|
2015-11-02 18:56:41 +01:00
|
|
|
expect(rendered).to have_selector("#piece_justificative_#{all_type_pj_procedure_id[1]}", "Nous l'avons récupéré pour vous.")
|
2015-09-28 10:32:41 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
context 'when dossier have pj' do
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content 'Documents administratifs' }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure have demarche link' do
|
|
|
|
let(:procedure) { create :procedure }
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content 'Documents administratifs' }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure have cerfa flag true' do
|
|
|
|
let(:procedure) {create(:procedure, cerfa_flag: true)}
|
|
|
|
|
|
|
|
it { expect(rendered).to have_content 'Documents administratifs' }
|
|
|
|
end
|
|
|
|
end
|
2015-09-28 10:32:41 +02:00
|
|
|
end
|