Merge branch 'main' into feature/prefill_repetible
This commit is contained in:
parent
4b3d403d7e
commit
4876d583b6
33 changed files with 613 additions and 76 deletions
|
@ -1,7 +1,7 @@
|
|||
describe Champs::CarteChamp do
|
||||
let(:champ) { Champs::CarteChamp.new(geo_areas: geo_areas, type_de_champ: create(:type_de_champ_carte)) }
|
||||
let(:value) { '' }
|
||||
let(:coordinates) { [[2.3859214782714844, 48.87442541960633], [2.3850631713867183, 48.87273183590832], [2.3809432983398438, 48.87081237174292], [2.3859214782714844, 48.87442541960633]] }
|
||||
let(:coordinates) { [[[2.3859214782714844, 48.87442541960633], [2.3850631713867183, 48.87273183590832], [2.3809432983398438, 48.87081237174292], [2.3859214782714844, 48.87442541960633]]] }
|
||||
let(:geo_json) do
|
||||
{
|
||||
"type" => 'Polygon',
|
||||
|
|
|
@ -6,9 +6,156 @@ describe Champs::EpciChamp, type: :model do
|
|||
Rails.cache.clear
|
||||
end
|
||||
|
||||
let(:champ) { described_class.new }
|
||||
describe 'validations' do
|
||||
describe 'code_departement', vcr: { cassette_name: 'api_geo_departements' } do
|
||||
subject { build(:champ_epci, code_departement: code_departement) }
|
||||
|
||||
context 'when nil' do
|
||||
let(:code_departement) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when empty' do
|
||||
let(:code_departement) { '' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'when included in the departement codes' do
|
||||
let(:code_departement) { "01" }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when not included in the departement codes' do
|
||||
let(:code_departement) { "totoro" }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'external_id' do
|
||||
let(:champ) { build(:champ_epci, code_departement: code_departement, external_id: nil) }
|
||||
|
||||
subject { champ }
|
||||
|
||||
before do
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
|
||||
champ.save!
|
||||
champ.update_columns(external_id: external_id)
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
context 'when code_departement is nil' do
|
||||
let(:code_departement) { nil }
|
||||
let(:external_id) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when code_departement is not nil and valid' do
|
||||
let(:code_departement) { "01" }
|
||||
|
||||
context 'when external_id is nil' do
|
||||
let(:external_id) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when external_id is empty' do
|
||||
let(:external_id) { '' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'when external_id is included in the epci codes of the departement' do
|
||||
let(:external_id) { '200042935' }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when external_id is not included in the epci codes of the departement' do
|
||||
let(:external_id) { 'totoro' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'value' do
|
||||
let(:champ) { build(:champ_epci, code_departement: code_departement, external_id: nil, value: nil) }
|
||||
|
||||
subject { champ }
|
||||
|
||||
before do
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
|
||||
champ.save!
|
||||
champ.update_columns(external_id: external_id, value: value)
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
context 'when code_departement is nil' do
|
||||
let(:code_departement) { nil }
|
||||
let(:external_id) { nil }
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when external_id is nil' do
|
||||
let(:code_departement) { '01' }
|
||||
let(:external_id) { nil }
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when code_departement and external_id are not nil and valid' do
|
||||
let(:code_departement) { '01' }
|
||||
let(:external_id) { '200042935' }
|
||||
|
||||
context 'when value is nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when value is empty' do
|
||||
let(:value) { '' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'when value is in departement epci names' do
|
||||
let(:value) { 'CA Haut - Bugey Agglomération' }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'when value is not in departement epci names' do
|
||||
let(:value) { 'totoro' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'value', vcr: { cassette_name: 'api_geo_epcis' } do
|
||||
let(:champ) { described_class.new }
|
||||
it 'with departement and code' do
|
||||
champ.code_departement = '01'
|
||||
champ.value = '200042935'
|
||||
|
|
|
@ -1516,8 +1516,8 @@ describe Dossier do
|
|||
{
|
||||
type: 'Feature',
|
||||
geometry: {
|
||||
'coordinates' => [[[2.428439855575562, 46.538476837725796], [2.4284291267395024, 46.53842148758162], [2.4282521009445195, 46.53841410755813], [2.42824137210846, 46.53847314771794], [2.428284287452698, 46.53847314771794], [2.428364753723145, 46.538487907747864], [2.4284291267395024, 46.538491597754714], [2.428439855575562, 46.538476837725796]]],
|
||||
'type' => 'Polygon'
|
||||
coordinates: [[[2.428439855575562, 46.538476837725796], [2.4284291267395024, 46.53842148758162], [2.4282521009445195, 46.53841410755813], [2.42824137210846, 46.53847314771794], [2.428284287452698, 46.53847314771794], [2.428364753723145, 46.538487907747864], [2.4284291267395024, 46.538491597754714], [2.428439855575562, 46.538476837725796]]],
|
||||
type: 'Polygon'
|
||||
},
|
||||
properties: {
|
||||
area: 103.6,
|
||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe GeoArea, type: :model do
|
|||
it { expect(geo_area.location).to eq("46°32'19\"N 2°25'42\"E") }
|
||||
end
|
||||
|
||||
describe '#rgeo_geometry' do
|
||||
describe '#geometry' do
|
||||
let(:geo_area) { build(:geo_area, :polygon, champ: nil) }
|
||||
let(:polygon) do
|
||||
{
|
||||
|
@ -47,9 +47,9 @@ RSpec.describe GeoArea, type: :model do
|
|||
|
||||
context 'polygon_with_extra_coordinate' do
|
||||
let(:geo_area) { build(:geo_area, :polygon_with_extra_coordinate, champ: nil) }
|
||||
before { geo_area.valid? }
|
||||
|
||||
it { expect(geo_area.geometry).not_to eq(polygon) }
|
||||
it { expect(geo_area.safe_geometry).to eq(polygon) }
|
||||
it { expect(geo_area.geometry).to eq(polygon) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -105,6 +105,34 @@ RSpec.describe PrefillDescription, type: :model do
|
|||
)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when the type de champ can have multiple values' do
|
||||
let(:type_de_champ) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure)) }
|
||||
|
||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
it 'builds the URL with array parameter' do
|
||||
expect(prefill_description.prefill_link).to eq(
|
||||
commencer_url(
|
||||
path: procedure.path,
|
||||
"champ_#{type_de_champ.to_typed_id}": type_de_champ.example_value
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#prefill_query', vcr: { cassette_name: 'api_geo_regions' } do
|
||||
|
@ -121,10 +149,43 @@ RSpec.describe PrefillDescription, type: :model do
|
|||
--data '{"champ_#{type_de_champ.to_typed_id}": "#{I18n.t("views.prefill_descriptions.edit.examples.#{type_de_champ.type_champ}")}", "champ_#{type_de_champ_repetition.to_typed_id}": #{TypesDeChamp::PrefillTypeDeChamp.build(type_de_champ_repetition).example_value}}'
|
||||
TEXT
|
||||
end
|
||||
|
||||
before { prefill_description.update(selected_type_de_champ_ids: [type_de_champ.id, type_de_champ_repetition.id]) }
|
||||
|
||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
|
||||
prefill_description.update(selected_type_de_champ_ids: [type_de_champ.id])
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
it "builds the query to create a new prefilled dossier" do
|
||||
expect(prefill_description.prefill_query).to eq(expected_query)
|
||||
end
|
||||
|
||||
context 'when the type de champ can have multiple values' do
|
||||
let(:type_de_champ) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure)) }
|
||||
let(:expected_query) do
|
||||
<<~TEXT
|
||||
curl --request POST '#{api_public_v1_dossiers_url(procedure)}' \\
|
||||
--header 'Content-Type: application/json' \\
|
||||
--data '{"champ_#{type_de_champ.to_typed_id}": #{type_de_champ.example_value}}'
|
||||
TEXT
|
||||
end
|
||||
|
||||
it 'builds the query with array parameter' do
|
||||
expect(prefill_description.prefill_query).to eq(expected_query)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,16 @@ RSpec.describe PrefillParams do
|
|||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
||||
VCR.insert_cassette('api_geo_regions')
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_regions')
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
context "when the stable ids match the TypeDeChamp of the corresponding procedure" do
|
||||
|
@ -76,7 +86,7 @@ RSpec.describe PrefillParams do
|
|||
|
||||
let(:params) { { "champ_#{type_de_champ.to_typed_id}" => value } }
|
||||
|
||||
it "builds an array of hash(id, value) matching the given params" do
|
||||
it "builds an array of hash matching the given params" do
|
||||
expect(prefill_params_array).to match([{ id: champ.id }.merge(attributes(champ, value))])
|
||||
end
|
||||
end
|
||||
|
@ -90,7 +100,7 @@ RSpec.describe PrefillParams do
|
|||
|
||||
let(:params) { { "champ_#{type_de_champ.to_typed_id}" => value } }
|
||||
|
||||
it "builds an array of hash(id, value) matching the given params" do
|
||||
it "builds an array of hash matching the given params" do
|
||||
expect(prefill_params_array).to match([{ id: champ.id }.merge(attributes(champ, value))])
|
||||
end
|
||||
end
|
||||
|
@ -127,6 +137,7 @@ RSpec.describe PrefillParams do
|
|||
it_behaves_like "a champ public value that is authorized", :drop_down_list, "value"
|
||||
it_behaves_like "a champ public value that is authorized", :regions, "03"
|
||||
it_behaves_like "a champ public value that is authorized", :departements, "03"
|
||||
it_behaves_like "a champ public value that is authorized", :epci, ['01', '200042935']
|
||||
|
||||
context "when the public type de champ is authorized (repetition)" do
|
||||
let(:types_de_champ_public) { [{ type: :repetition, children: [{ type: :text }] }] }
|
||||
|
@ -159,7 +170,8 @@ RSpec.describe PrefillParams do
|
|||
it_behaves_like "a champ private value that is authorized", :checkbox, "false"
|
||||
it_behaves_like "a champ private value that is authorized", :drop_down_list, "value"
|
||||
it_behaves_like "a champ private value that is authorized", :regions, "93"
|
||||
it_behaves_like "a champ public value that is authorized", :departements, "03"
|
||||
it_behaves_like "a champ private value that is authorized", :departements, "03"
|
||||
it_behaves_like "a champ private value that is authorized", :epci, ['01', '200042935']
|
||||
|
||||
context "when the private type de champ is authorized (repetition)" do
|
||||
let(:types_de_champ_private) { [{ type: :repetition, children: [{ type: :text }] }] }
|
||||
|
|
|
@ -252,6 +252,7 @@ describe TypeDeChamp do
|
|||
it_behaves_like "a prefillable type de champ", :type_de_champ_regions
|
||||
it_behaves_like "a prefillable type de champ", :type_de_champ_repetition
|
||||
it_behaves_like "a prefillable type de champ", :type_de_champ_departements
|
||||
it_behaves_like "a prefillable type de champ", :type_de_champ_epci
|
||||
|
||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_number
|
||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_communes
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
|
||||
let(:type_de_champ) { build(:type_de_champ_epci) }
|
||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
end
|
||||
|
||||
describe 'ancestors' do
|
||||
subject { described_class.new(type_de_champ) }
|
||||
|
||||
it { is_expected.to be_kind_of(TypesDeChamp::PrefillEpciTypeDeChamp) }
|
||||
end
|
||||
|
||||
describe '#possible_values' do
|
||||
let(:expected_values) do
|
||||
departements.map { |departement| "#{departement[:code]} (#{departement[:name]}) : https://geo.api.gouv.fr/epcis?codeDepartement=#{departement[:code]}" }
|
||||
end
|
||||
subject(:possible_values) { described_class.new(type_de_champ).possible_values }
|
||||
|
||||
before do
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
it { expect(possible_values).to match(expected_values) }
|
||||
end
|
||||
|
||||
describe '#example_value' do
|
||||
let(:departement_code) { departements.pick(:code) }
|
||||
let(:epci_code) { APIGeoService.epcis(departement_code).pick(:code) }
|
||||
subject(:example_value) { described_class.new(type_de_champ).example_value }
|
||||
|
||||
before do
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
it { is_expected.to eq([departement_code, epci_code]) }
|
||||
end
|
||||
|
||||
describe '#to_assignable_attributes' do
|
||||
subject(:to_assignable_attributes) { described_class.build(type_de_champ).to_assignable_attributes(champ, value) }
|
||||
|
||||
context 'when the value is nil' do
|
||||
let(:value) { nil }
|
||||
it { is_expected.to match({ code_departement: nil, value: nil }) }
|
||||
end
|
||||
|
||||
context 'when the value is empty' do
|
||||
let(:value) { '' }
|
||||
it { is_expected.to match({ code_departement: nil, value: nil }) }
|
||||
end
|
||||
|
||||
context 'when the value is a string' do
|
||||
let(:value) { 'hello' }
|
||||
it { is_expected.to match({ code_departement: nil, value: nil }) }
|
||||
end
|
||||
|
||||
context 'when the value is an array of one element' do
|
||||
let(:value) { ['01'] }
|
||||
it { is_expected.to match({ code_departement: '01', value: nil }) }
|
||||
end
|
||||
|
||||
context 'when the value is an array of two elements' do
|
||||
let(:value) { ['01', '200042935'] }
|
||||
it { is_expected.to match({ code_departement: '01', value: '200042935' }) }
|
||||
end
|
||||
|
||||
context 'when the value is an array of three or more elements' do
|
||||
let(:value) { ['01', '200042935', 'hello'] }
|
||||
it { is_expected.to match({ code_departement: '01', value: '200042935' }) }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def departements
|
||||
APIGeoService.departements.sort_by { |departement| departement[:code] }
|
||||
end
|
||||
end
|
|
@ -37,6 +37,12 @@ RSpec.describe TypesDeChamp::PrefillTypeDeChamp, type: :model do
|
|||
it { expect(built).to be_kind_of(TypesDeChamp::PrefillDepartementTypeDeChamp) }
|
||||
end
|
||||
|
||||
context 'when the type de champ is a epci' do
|
||||
let(:type_de_champ) { build(:type_de_champ_epci) }
|
||||
|
||||
it { expect(built).to be_kind_of(TypesDeChamp::PrefillEpciTypeDeChamp) }
|
||||
end
|
||||
|
||||
context 'when any other type de champ' do
|
||||
let(:type_de_champ) { build(:type_de_champ_date) }
|
||||
|
||||
|
|
|
@ -22,5 +22,6 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do
|
|||
expect(page).to have_field(text_repetition_libelle, with: text_repetition_value)
|
||||
expect(page).to have_field(integer_repetition_libelle, with: integer_repetition_value)
|
||||
expect(page).to have_field(type_de_champ_datetime.libelle, with: datetime_value)
|
||||
expect(page).to have_field(type_de_champ_epci.libelle, with: epci_value.last)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,22 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
|
|||
published_at: Time.zone.now)
|
||||
login_as administrateur.user, scope: :user
|
||||
end
|
||||
context 'Visit all admin procedures' do
|
||||
let(:download_dir) { Rails.root.join('tmp/capybara') }
|
||||
let(:download_file_pattern) { download_dir.join('*.xlsx') }
|
||||
|
||||
scenario do
|
||||
Dir[download_file_pattern].map { File.delete(_1) }
|
||||
visit all_admin_procedures_path
|
||||
|
||||
click_on "Exporter les résultats"
|
||||
Timeout.timeout(Capybara.default_max_wait_time,
|
||||
Timeout::Error,
|
||||
"File download timeout! can't download procedure/all.xlsx") do
|
||||
sleep 0.1 until !Dir[download_file_pattern].empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'Cloning a procedure owned by the current admin' do
|
||||
scenario do
|
||||
visit admin_procedures_path
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe 'Prefilling a dossier (with a GET request):' do
|
||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
||||
|
||||
let(:password) { 'my-s3cure-p4ssword' }
|
||||
|
||||
let(:procedure) { create(:procedure, :published, opendata: true) }
|
||||
|
@ -16,6 +18,21 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
|
||||
let(:text_repetition_value) { "First repetition text" }
|
||||
let(:integer_repetition_value) { "42" }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
context 'when authenticated' do
|
||||
it_behaves_like "the user has got a prefilled dossier, owned by themselves" do
|
||||
|
@ -35,7 +52,8 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
\"#{sub_type_de_champs_repetition.second.to_typed_id}\": \"#{integer_repetition_value}\"
|
||||
}"
|
||||
],
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
)
|
||||
|
||||
click_on "Poursuivre mon dossier prérempli"
|
||||
|
@ -55,7 +73,8 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
\"#{sub_type_de_champs_repetition.second.to_typed_id}\": \"#{integer_repetition_value}\"
|
||||
}"
|
||||
],
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe 'Prefilling a dossier (with a POST request):' do
|
||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
||||
|
||||
let(:password) { 'my-s3cure-p4ssword' }
|
||||
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
|
@ -16,6 +18,21 @@ describe 'Prefilling a dossier (with a POST request):' do
|
|||
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
|
||||
let(:text_repetition_value) { "First repetition text" }
|
||||
let(:integer_repetition_value) { "42" }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
scenario "the user get the URL of a prefilled orphan brouillon dossier" do
|
||||
dossier_url = create_and_prefill_dossier_with_post_request
|
||||
|
@ -110,7 +127,8 @@ describe 'Prefilling a dossier (with a POST request):' do
|
|||
\"#{sub_type_de_champs_repetition.second.to_typed_id}\": \"#{integer_repetition_value}\"
|
||||
}"
|
||||
],
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
}.to_json
|
||||
JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue