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
|
2015-09-23 10:02:01 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:siret) { '42149333900020' }
|
|
|
|
let(:siren) { siret[0...9] }
|
|
|
|
context 'when user is not logged in' do
|
|
|
|
before do
|
2015-09-23 19:20:03 +02:00
|
|
|
visit users_siret_path(procedure_id: procedure.id)
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|
|
|
|
scenario 'he is redirected to login page' do
|
|
|
|
expect(page).to have_css('#login_user')
|
|
|
|
end
|
|
|
|
context 'when he enter login information' do
|
|
|
|
before do
|
2015-10-07 12:01:05 +02:00
|
|
|
within('#new_user') do
|
|
|
|
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
|
2015-09-23 10:02:01 +02:00
|
|
|
expect(page).to have_css('#pro_section')
|
|
|
|
end
|
|
|
|
context 'when enter a siret' do
|
|
|
|
before do
|
|
|
|
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
2015-11-16 11:23:29 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
2015-09-23 10:02:01 +02:00
|
|
|
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
2015-11-16 11:23:29 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
|
|
|
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
2015-09-23 10:02:01 +02:00
|
|
|
page.find_by_id('siret').set siret
|
|
|
|
page.click_on 'Commencer'
|
|
|
|
end
|
|
|
|
scenario 'he is redirected to recap info entreprise page' do
|
|
|
|
expect(page).to have_css('#recap_info_entreprise')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|