2015-09-24 10:30:29 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'user path for dossier creation' do
|
|
|
|
let(:user) { create(:user) }
|
2016-07-19 16:10:50 +02:00
|
|
|
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
2015-09-24 10:30:29 +02:00
|
|
|
let(:siret) { '53272417600013' }
|
|
|
|
let(:siren) { siret[0...9] }
|
2016-06-09 17:49:38 +02:00
|
|
|
|
2016-06-20 13:57:57 +02:00
|
|
|
context 'user arrives on siret page', js: true do
|
2015-09-24 10:30:29 +02:00
|
|
|
before do
|
2016-06-29 17:35:34 +02:00
|
|
|
visit commencer_path(procedure_path: procedure.path)
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'he is redirected on login page' do
|
2017-06-13 17:46:08 +02:00
|
|
|
expect(page).to have_css('#new_user')
|
|
|
|
expect(page).to have_css('.procedure-logos')
|
|
|
|
expect(page).to have_content(procedure.libelle)
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'user sign_in' do
|
|
|
|
before do
|
2017-06-13 17:46:08 +02:00
|
|
|
within('#new_user') do
|
2015-10-07 12:01:05 +02:00
|
|
|
page.find_by_id('user_email').set user.email
|
|
|
|
page.find_by_id('user_password').set user.password
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
scenario 'redirects to siret page' do
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#dossier-siret')
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
context 'sets siret' do
|
|
|
|
before do
|
2018-05-09 12:03:04 +02:00
|
|
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
|
2018-05-09 12:03:04 +02:00
|
|
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/)
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
2015-11-16 11:23:29 +01:00
|
|
|
|
2018-05-09 12:03:04 +02:00
|
|
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/)
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
2018-05-09 12:03:04 +02:00
|
|
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/)
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 404, body: '')
|
2015-12-11 12:36:44 +01:00
|
|
|
|
2017-04-12 11:12:05 +02:00
|
|
|
page.find_by_id('dossier-siret').set siret
|
2016-06-20 13:57:57 +02:00
|
|
|
page.click_on 'Valider'
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
2016-06-20 13:57:57 +02:00
|
|
|
|
2015-09-24 10:30:29 +02:00
|
|
|
scenario 'user is on page recap info entreprise' do
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#recap-info-entreprise')
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
2016-06-20 13:57:57 +02:00
|
|
|
|
|
|
|
context 'when user would like change siret' do
|
|
|
|
before do
|
|
|
|
page.click_on('Changer de SIRET')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'redirects to siret page' do
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#dossier-siret')
|
2016-06-20 13:57:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-24 10:30:29 +02:00
|
|
|
context 'when validating info entreprise recap page' do
|
|
|
|
before do
|
|
|
|
page.check('dossier_autorisation_donnees')
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('etape_suivante').click
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
2018-02-21 18:36:06 +01:00
|
|
|
scenario 'user is on edition page' do
|
|
|
|
expect(page).to have_current_path(modifier_dossier_path(Dossier.last))
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
context 'user fill and validate description page' do
|
|
|
|
before do
|
2018-02-21 18:36:06 +01:00
|
|
|
page.find_by_id("dossier_champs_attributes_0_value").set 'Mon super projet'
|
|
|
|
click_on 'Soumettre le dossier'
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
2018-02-27 09:49:58 +01:00
|
|
|
scenario 'user is on merci page' do
|
|
|
|
expect(page).to have_current_path(merci_dossier_path(Dossier.last))
|
2016-12-14 18:41:33 +01:00
|
|
|
end
|
2015-09-24 10:30:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-09 17:49:38 +02:00
|
|
|
|
|
|
|
context 'user cannot access non-published procedures' do
|
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
before do
|
|
|
|
visit new_users_dossiers_path(procedure_id: procedure.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user is on home page', vcr: { cassette_name: 'complete_demande_spec' } do
|
|
|
|
expect(page).to have_content('La procédure n\'existe pas')
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|