2015-08-31 09:50:54 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'user is on description page' do
|
2016-07-19 16:10:50 +02:00
|
|
|
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) }
|
2016-11-02 16:33:01 +01:00
|
|
|
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) }
|
2016-04-15 15:32:15 +02:00
|
|
|
|
2015-08-31 09:50:54 +02:00
|
|
|
before do
|
2016-04-15 15:32:15 +02:00
|
|
|
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
|
|
|
|
2015-09-23 19:20:03 +02:00
|
|
|
visit users_dossier_description_path dossier
|
2015-10-09 14:43:19 +02:00
|
|
|
|
2017-06-13 17:46:08 +02:00
|
|
|
within('#new_user') do
|
2015-10-09 14:43:19 +02:00
|
|
|
page.find_by_id('user_email').set dossier.user.email
|
|
|
|
page.find_by_id('user_password').set dossier.user.password
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
2015-08-31 09:50:54 +02:00
|
|
|
end
|
2016-04-15 15:32:15 +02:00
|
|
|
|
2017-04-12 11:12:05 +02:00
|
|
|
it { expect(page).to have_css('#description-page') }
|
2015-08-31 09:50:54 +02:00
|
|
|
|
|
|
|
context 'he fill description fields' do
|
|
|
|
before do
|
2016-07-19 16:10:50 +02:00
|
|
|
find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom'
|
2015-08-31 09:50:54 +02:00
|
|
|
end
|
|
|
|
context 'before submit' do
|
|
|
|
it 'dossier cerfa is empty' do
|
|
|
|
expect(dossier.cerfa).to be_empty
|
|
|
|
end
|
2015-09-21 17:59:03 +02:00
|
|
|
it 'pieces_justificatives are empty' do
|
|
|
|
dossier.pieces_justificatives.each do |piece_justificative|
|
|
|
|
expect(piece_justificative).to be_empty
|
2015-08-31 09:50:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-05-13 16:08:51 +02:00
|
|
|
context 'he adds cerfa', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa' } do
|
2015-08-31 09:50:54 +02:00
|
|
|
before do
|
|
|
|
attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf'))
|
2015-09-28 10:32:41 +02:00
|
|
|
click_on("Soumettre mon dossier")
|
2015-08-31 09:50:54 +02:00
|
|
|
dossier.reload
|
|
|
|
end
|
|
|
|
it 'fills dossier cerfa' do
|
|
|
|
expect(dossier.cerfa).not_to be_empty
|
|
|
|
end
|
|
|
|
end
|
2016-05-13 16:08:51 +02:00
|
|
|
context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do
|
2015-08-31 09:50:54 +02:00
|
|
|
before do
|
2018-01-30 15:16:05 +01:00
|
|
|
file_input_id = "piece_justificative_#{dossier.types_de_piece_justificative.first.id.to_s}"
|
2016-02-04 10:39:25 +01:00
|
|
|
attach_file(file_input_id, File.path('spec/support/files/dossierPDF.pdf'))
|
2015-09-28 10:32:41 +02:00
|
|
|
click_on('Soumettre mon dossier')
|
2015-08-31 09:50:54 +02:00
|
|
|
dossier.reload
|
|
|
|
end
|
2015-09-21 17:59:03 +02:00
|
|
|
scenario 'fills the given piece_justificative' do
|
|
|
|
expect(dossier.pieces_justificatives.first).not_to be_empty
|
2015-08-31 09:50:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|