2016-12-19 17:15:59 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-02-13 11:57:35 +01:00
|
|
|
feature 'As a User I wanna create a dossier' do
|
2016-12-19 17:15:59 +01:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:siret) { '40307130100044' }
|
|
|
|
let(:siren) { siret[0...9] }
|
|
|
|
|
|
|
|
context 'Right after sign_in I shall see inscription by credentials/siret, I can create a new Dossier' do
|
|
|
|
let(:procedure_with_siret) { create(:procedure, :published, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
|
|
|
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
|
|
|
|
2017-03-28 18:06:49 +02:00
|
|
|
context 'Identification for individual' do
|
|
|
|
before do
|
|
|
|
login_as user, scope: :user
|
|
|
|
visit commencer_path(procedure_path: procedure_for_individual.path)
|
|
|
|
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
|
|
|
|
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
|
|
|
|
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario "with a proper date input field for birthdate (type='date' supported)" do
|
|
|
|
fill_in 'dossier_individual_attributes_birthdate', with: '1987-10-14'
|
|
|
|
page.find_by_id('etape_suivante').click
|
|
|
|
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
|
|
|
page.find_by_id('etape_suivante').click
|
|
|
|
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
|
|
|
page.find_by_id('suivant').click
|
2017-07-25 17:26:40 +02:00
|
|
|
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
2017-03-28 18:06:49 +02:00
|
|
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario "with a basic text input field for birthdate (type='date' unsupported)" do
|
|
|
|
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
|
|
|
|
page.find_by_id('etape_suivante').click
|
|
|
|
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
|
|
|
page.find_by_id('etape_suivante').click
|
|
|
|
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
|
|
|
page.find_by_id('suivant').click
|
2017-07-25 17:26:40 +02:00
|
|
|
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
2017-03-28 18:06:49 +02:00
|
|
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
|
|
|
end
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
scenario 'Identification through siret', vcr: { cassette_name: 'search_ban_paris' }, js: true do
|
2016-12-19 17:15:59 +01:00
|
|
|
login_as user, scope: :user
|
|
|
|
visit commencer_path(procedure_path: procedure_with_siret.path)
|
2017-02-13 11:57:35 +01:00
|
|
|
expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
|
2017-04-12 11:12:05 +02:00
|
|
|
fill_in 'dossier-siret', with: siret
|
2017-12-11 15:31:45 +01:00
|
|
|
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
2017-12-11 15:31:45 +01:00
|
|
|
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
2017-12-11 15:31:45 +01:00
|
|
|
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/exercices/#{siret}?token=#{SIADETOKEN}")
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
2017-12-11 15:31:45 +01:00
|
|
|
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/associations/#{siret}?token=#{SIADETOKEN}")
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(status: 404, body: '')
|
2017-04-12 11:12:05 +02:00
|
|
|
page.find_by_id('dossier-siret').set siret
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('submit-siret').click
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#recap-info-entreprise')
|
2016-12-19 17:15:59 +01:00
|
|
|
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('etape_suivante').click
|
2017-02-13 11:57:35 +01:00
|
|
|
expect(page).to have_current_path(users_dossier_carte_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('etape_suivante').click
|
2017-02-13 11:57:35 +01:00
|
|
|
fill_in "champs_#{procedure_with_siret.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('suivant').click
|
2017-02-13 11:57:35 +01:00
|
|
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true)
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|