2015-09-23 10:02:01 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-23 16:56:30 +02:00
|
|
|
feature 'user arrive on siret page' do
|
2016-06-09 17:49:38 +02:00
|
|
|
let(:procedure) { create(:procedure, :published) }
|
2015-09-23 10:02:01 +02:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:siret) { '42149333900020' }
|
|
|
|
let(:siren) { siret[0...9] }
|
2015-12-24 15:10:20 +01:00
|
|
|
|
2017-02-14 15:20:10 +01:00
|
|
|
context 'when user is not logged in' do
|
2015-09-23 10:02:01 +02:00
|
|
|
before do
|
2015-12-03 12:00:22 +01:00
|
|
|
visit new_users_dossiers_path(procedure_id: procedure.id)
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|
|
|
|
scenario 'he is redirected to login page' do
|
2017-06-13 17:46:08 +02:00
|
|
|
expect(page).to have_css('#new_user')
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|
|
|
|
context 'when he enter login information' 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-23 10:02:01 +02:00
|
|
|
end
|
2015-09-23 16:56:30 +02:00
|
|
|
scenario 'he is redirected to siret page to enter a siret' do
|
2016-06-20 13:57:57 +02:00
|
|
|
expect(page).to have_css('#new_siret')
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|
2017-02-14 15:20:10 +01:00
|
|
|
context 'when enter a siret', js: true do
|
2015-09-23 10:02:01 +02:00
|
|
|
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(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
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'))
|
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-23 10:02:01 +02:00
|
|
|
end
|
|
|
|
scenario 'he is redirected to recap info entreprise page' do
|
2017-02-14 15:20:10 +01:00
|
|
|
wait_for_ajax
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#recap-info-entreprise')
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|