chore(spec): remove memory store cache from tests
This commit is contained in:
parent
98caf41a36
commit
5abb6a8f12
29 changed files with 3976 additions and 398 deletions
|
@ -15,18 +15,15 @@ describe Administrateurs::ProceduresController, type: :controller do
|
||||||
let(:zone_ids) { [zone.id] }
|
let(:zone_ids) { [zone.id] }
|
||||||
let(:tags) { "[\"planete\",\"environnement\"]" }
|
let(:tags) { "[\"planete\",\"environnement\"]" }
|
||||||
|
|
||||||
describe '#apercu', vcr: { cassette_name: 'api_geo_all' } do
|
describe '#apercu' do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :with_all_champs) }
|
let(:procedure) { create(:procedure, :with_all_champs) }
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
subject { get :apercu, params: { id: procedure.id } }
|
subject { get :apercu, params: { id: procedure.id } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(admin.user)
|
sign_in(admin.user)
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
|
|
@ -4,13 +4,6 @@ describe API::V1::DossiersController do
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) }
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) }
|
||||||
let(:wrong_procedure) { create(:procedure) }
|
let(:wrong_procedure) { create(:procedure) }
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(described_class).to be < APIController }
|
it { expect(described_class).to be < APIController }
|
||||||
|
|
||||||
describe 'GET index (with bearer token)' do
|
describe 'GET index (with bearer token)' do
|
||||||
|
@ -265,7 +258,7 @@ describe API::V1::DossiersController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'departement', vcr: { cassette_name: 'api_geo_departements' } do
|
describe 'departement' do
|
||||||
let(:procedure) { create(:procedure, :with_departement, administrateur: admin) }
|
let(:procedure) { create(:procedure, :with_departement, administrateur: admin) }
|
||||||
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure: procedure) }
|
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure: procedure) }
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ describe API::V2::GraphqlController do
|
||||||
let(:dossiers) { [dossier] }
|
let(:dossiers) { [dossier] }
|
||||||
let(:instructeur) { create(:instructeur, followed_dossiers: dossiers) }
|
let(:instructeur) { create(:instructeur, followed_dossiers: dossiers) }
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
def compute_checksum_in_chunks(io)
|
def compute_checksum_in_chunks(io)
|
||||||
Digest::MD5.new.tap do |checksum|
|
Digest::MD5.new.tap do |checksum|
|
||||||
while (chunk = io.read(5.megabytes))
|
while (chunk = io.read(5.megabytes))
|
||||||
|
@ -40,12 +38,7 @@ describe API::V2::GraphqlController do
|
||||||
blob
|
blob
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before { instructeur.assign_to_procedure(procedure) }
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
|
|
||||||
instructeur.assign_to_procedure(procedure)
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:query) do
|
let(:query) do
|
||||||
"{
|
"{
|
||||||
|
@ -407,7 +400,7 @@ describe API::V2::GraphqlController do
|
||||||
dossier
|
dossier
|
||||||
end
|
end
|
||||||
|
|
||||||
context "for individual", vcr: { cassette_name: 'api_geo_all' } do
|
context "for individual" do
|
||||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
|
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
|
||||||
let(:query) do
|
let(:query) do
|
||||||
"{
|
"{
|
||||||
|
|
|
@ -193,7 +193,7 @@ describe API::V2::GraphqlController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'getDemarcheDescriptor', vcr: { cassette_name: 'api_geo_regions' } do
|
context 'getDemarcheDescriptor' do
|
||||||
let(:operation_name) { 'getDemarcheDescriptor' }
|
let(:operation_name) { 'getDemarcheDescriptor' }
|
||||||
let(:types_de_champ_public) { [{ type: :text }, { type: :piece_justificative }, { type: :regions }] }
|
let(:types_de_champ_public) { [{ type: :text }, { type: :piece_justificative }, { type: :regions }] }
|
||||||
|
|
||||||
|
|
4032
spec/fixtures/cassettes/api_geo_communes.yml
vendored
4032
spec/fixtures/cassettes/api_geo_communes.yml
vendored
File diff suppressed because one or more lines are too long
|
@ -26,7 +26,7 @@ RSpec.describe Types::DossierType, type: :graphql do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'dossier with champs', vcr: { cassette_name: 'graphql_communes' } do
|
describe 'dossier with champs' do
|
||||||
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :communes }, { type: :address }, { type: :siret }]) }
|
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :communes }, { type: :address }, { type: :siret }]) }
|
||||||
let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) }
|
let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) }
|
||||||
let(:query) { DOSSIER_WITH_CHAMPS_QUERY }
|
let(:query) { DOSSIER_WITH_CHAMPS_QUERY }
|
||||||
|
@ -48,13 +48,7 @@ RSpec.describe Types::DossierType, type: :graphql do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
before { dossier.champs_public.second.update(data: address) }
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
dossier.champs_public.second.update(data: address)
|
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(data[:dossier][:champs][0][:__typename]).to eq "CommuneChamp"
|
expect(data[:dossier][:champs][0][:__typename]).to eq "CommuneChamp"
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
describe '20220705164551_remove_unused_champs' do
|
describe '20220705164551_remove_unused_champs' do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
let(:rake_task) { Rake::Task['after_party:remove_unused_champs'] }
|
let(:rake_task) { Rake::Task['after_party:remove_unused_champs'] }
|
||||||
let(:procedure) { create(:procedure, :with_all_champs) }
|
let(:procedure) { create(:procedure, :with_all_champs) }
|
||||||
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) }
|
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) }
|
||||||
|
@ -11,15 +9,10 @@ describe '20220705164551_remove_unused_champs' do
|
||||||
rake_task.invoke
|
rake_task.invoke
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before { champ_repetition.champs.first.update(type_de_champ: create(:type_de_champ)) }
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
|
|
||||||
champ_repetition.champs.first.update(type_de_champ: create(:type_de_champ))
|
|
||||||
end
|
|
||||||
after { rake_task.reenable }
|
after { rake_task.reenable }
|
||||||
|
|
||||||
describe 'remove_unused_champs', vcr: { cassette_name: 'api_geo_all' } do
|
describe 'remove_unused_champs' do
|
||||||
it "with bad champs" do
|
it "with bad champs" do
|
||||||
expect(Champ.where(dossier: dossier).count).to eq(40)
|
expect(Champ.where(dossier: dossier).count).to eq(40)
|
||||||
run_task
|
run_task
|
||||||
|
|
|
@ -146,18 +146,11 @@ describe Champ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'for_export', vcr: { cassette_name: 'api_geo_all' } do
|
describe 'for_export' do
|
||||||
let(:type_de_champ) { create(:type_de_champ) }
|
let(:type_de_champ) { create(:type_de_champ) }
|
||||||
let(:champ) { type_de_champ.champ.build(value: value) }
|
let(:champ) { type_de_champ.champ.build(value: value) }
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
before { champ.save }
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
|
|
||||||
champ.save
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type_de_champ is text' do
|
context 'when type_de_champ is text' do
|
||||||
let(:value) { '123' }
|
let(:value) { '123' }
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
describe Champs::CommuneChamp do
|
describe Champs::CommuneChamp do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:code_insee) { '63102' }
|
let(:code_insee) { '63102' }
|
||||||
let(:code_postal) { '63290' }
|
let(:code_postal) { '63290' }
|
||||||
let(:code_departement) { '63' }
|
let(:code_departement) { '63' }
|
||||||
|
|
||||||
describe 'value', vcr: { cassette_name: 'api_geo_communes' } do
|
describe 'value' do
|
||||||
let(:champ) { create(:champ_communes, code_postal: code_postal) }
|
let(:champ) { create(:champ_communes, code_postal: code_postal) }
|
||||||
|
|
||||||
it 'with code_postal' do
|
it 'with code_postal' do
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
describe Champs::DepartementChamp, type: :model do
|
describe Champs::DepartementChamp, type: :model do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
describe 'validations' do
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'validations', vcr: { cassette_name: 'api_geo_departements' } do
|
|
||||||
describe 'external link' do
|
describe 'external link' do
|
||||||
subject { build(:champ_departements, external_id: external_id) }
|
subject { build(:champ_departements, external_id: external_id) }
|
||||||
|
|
||||||
|
@ -66,7 +59,7 @@ describe Champs::DepartementChamp, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'value', vcr: { cassette_name: 'api_geo_departements' } do
|
describe 'value' do
|
||||||
let(:champ) { described_class.new }
|
let(:champ) { described_class.new }
|
||||||
|
|
||||||
it 'with code having 2 chars' do
|
it 'with code having 2 chars' do
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
describe Champs::EpciChamp, type: :model do
|
describe Champs::EpciChamp, type: :model do
|
||||||
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 'validations' do
|
describe 'validations' do
|
||||||
describe 'code_departement', vcr: { cassette_name: 'api_geo_departements' } do
|
describe 'code_departement' do
|
||||||
subject { build(:champ_epci, code_departement: code_departement) }
|
subject { build(:champ_epci, code_departement: code_departement) }
|
||||||
|
|
||||||
context 'when nil' do
|
context 'when nil' do
|
||||||
|
@ -41,18 +34,10 @@ describe Champs::EpciChamp, type: :model do
|
||||||
subject { champ }
|
subject { champ }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
VCR.insert_cassette('api_geo_departements')
|
|
||||||
VCR.insert_cassette('api_geo_epcis')
|
|
||||||
|
|
||||||
champ.save!
|
champ.save!
|
||||||
champ.update_columns(external_id: external_id)
|
champ.update_columns(external_id: external_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code_departement is nil' do
|
context 'when code_departement is nil' do
|
||||||
let(:code_departement) { nil }
|
let(:code_departement) { nil }
|
||||||
let(:external_id) { nil }
|
let(:external_id) { nil }
|
||||||
|
@ -95,18 +80,10 @@ describe Champs::EpciChamp, type: :model do
|
||||||
subject { champ }
|
subject { champ }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
VCR.insert_cassette('api_geo_departements')
|
|
||||||
VCR.insert_cassette('api_geo_epcis')
|
|
||||||
|
|
||||||
champ.save!
|
champ.save!
|
||||||
champ.update_columns(external_id: external_id, value: value)
|
champ.update_columns(external_id: external_id, value: value)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code_departement is nil' do
|
context 'when code_departement is nil' do
|
||||||
let(:code_departement) { nil }
|
let(:code_departement) { nil }
|
||||||
let(:external_id) { nil }
|
let(:external_id) { nil }
|
||||||
|
@ -154,7 +131,7 @@ describe Champs::EpciChamp, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'value', vcr: { cassette_name: 'api_geo_epcis' } do
|
describe 'value' do
|
||||||
let(:champ) { described_class.new }
|
let(:champ) { described_class.new }
|
||||||
it 'with departement and code' do
|
it 'with departement and code' do
|
||||||
champ.code_departement = '01'
|
champ.code_departement = '01'
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
describe Champs::RegionChamp, type: :model do
|
describe Champs::RegionChamp, type: :model do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
describe 'validations' do
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'validations', vcr: { cassette_name: 'api_geo_regions' } do
|
|
||||||
describe 'external link' do
|
describe 'external link' do
|
||||||
subject { build(:champ_regions, external_id: external_id) }
|
subject { build(:champ_regions, external_id: external_id) }
|
||||||
|
|
||||||
|
@ -66,7 +59,7 @@ describe Champs::RegionChamp, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'value', vcr: { cassette_name: 'api_geo_regions' } do
|
describe 'value' do
|
||||||
let(:champ) { described_class.new }
|
let(:champ) { described_class.new }
|
||||||
|
|
||||||
it 'with code' do
|
it 'with code' do
|
||||||
|
|
|
@ -1573,7 +1573,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "champs_for_export", vcr: { cassette_name: 'api_geo_communes' } do
|
describe "champs_for_export" do
|
||||||
context 'with a unconditionnal procedure' do
|
context 'with a unconditionnal procedure' do
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_datetime, :with_yes_no, :with_explication, :with_commune, :with_repetition, zones: [create(:zone)]) }
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_datetime, :with_yes_no, :with_explication, :with_commune, :with_repetition, zones: [create(:zone)]) }
|
||||||
let(:text_type_de_champ) { procedure.active_revision.types_de_champ_public.find { |type_de_champ| type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:text) } }
|
let(:text_type_de_champ) { procedure.active_revision.types_de_champ_public.find { |type_de_champ| type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:text) } }
|
||||||
|
@ -1749,14 +1749,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#destroy", vcr: { cassette_name: 'api_geo_all' } do
|
describe "#destroy" do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :with_all_champs, :with_all_annotations) }
|
let(:procedure) { create(:procedure, :with_all_champs, :with_all_annotations) }
|
||||||
let(:transfer) { create(:dossier_transfer) }
|
let(:transfer) { create(:dossier_transfer) }
|
||||||
let(:dossier) { create(:dossier, :with_populated_champs, :with_populated_annotations, transfer: transfer, procedure: procedure) }
|
let(:dossier) { create(:dossier, :with_populated_champs, :with_populated_annotations, transfer: transfer, procedure: procedure) }
|
||||||
|
|
|
@ -86,7 +86,7 @@ RSpec.describe PrefillDescription, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#prefill_link', vcr: { cassette_name: 'api_geo_regions' } do
|
describe '#prefill_link' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ_text) { build(:type_de_champ_text, procedure: procedure) }
|
let(:type_de_champ_text) { build(:type_de_champ_text, procedure: procedure) }
|
||||||
let(:type_de_champ_epci) { build(:type_de_champ_epci, procedure: procedure) }
|
let(:type_de_champ_epci) { build(:type_de_champ_epci, procedure: procedure) }
|
||||||
|
@ -95,23 +95,10 @@ RSpec.describe PrefillDescription, type: :model do
|
||||||
let(:region_repetition) { prefillable_subchamps.third }
|
let(:region_repetition) { prefillable_subchamps.third }
|
||||||
let(:prefill_description) { described_class.new(procedure) }
|
let(:prefill_description) { described_class.new(procedure) }
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
before do
|
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_text.id, type_de_champ_epci.id, type_de_champ_repetition.id])
|
prefill_description.update(selected_type_de_champ_ids: [type_de_champ_text.id, type_de_champ_epci.id, type_de_champ_repetition.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "builds the URL to create a new prefilled dossier" do
|
it "builds the URL to create a new prefilled dossier" do
|
||||||
expect(prefill_description.prefill_link).to eq(
|
expect(prefill_description.prefill_link).to eq(
|
||||||
CGI.unescape(
|
CGI.unescape(
|
||||||
|
@ -126,7 +113,7 @@ RSpec.describe PrefillDescription, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#prefill_query', vcr: { cassette_name: 'api_geo_regions' } do
|
describe '#prefill_query' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
||||||
let(:type_de_champ_epci) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure), procedure.active_revision) }
|
let(:type_de_champ_epci) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure), procedure.active_revision) }
|
||||||
|
@ -144,23 +131,10 @@ RSpec.describe PrefillDescription, type: :model do
|
||||||
TEXT
|
TEXT
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
before do
|
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_text.id, type_de_champ_epci.id, type_de_champ_repetition.id])
|
prefill_description.update(selected_type_de_champ_ids: [type_de_champ_text.id, type_de_champ_epci.id, type_de_champ_repetition.id])
|
||||||
end
|
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
|
it "builds the query to create a new prefilled dossier" do
|
||||||
expect(prefill_description.prefill_query).to eq(expected_query)
|
expect(prefill_description.prefill_query).to eq(expected_query)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
RSpec.describe PrefillParams do
|
RSpec.describe PrefillParams do
|
||||||
describe "#to_a", vcr: { cassette_name: 'api_geo_all' } do
|
describe "#to_a" do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, types_de_champ_public:, types_de_champ_private:) }
|
let(:procedure) { create(:procedure, :published, types_de_champ_public:, types_de_champ_private:) }
|
||||||
let(:dossier) { create(:dossier, :brouillon, procedure: procedure) }
|
let(:dossier) { create(:dossier, :brouillon, procedure: procedure) }
|
||||||
let(:types_de_champ_public) { [] }
|
let(:types_de_champ_public) { [] }
|
||||||
|
@ -9,23 +7,6 @@ RSpec.describe PrefillParams do
|
||||||
|
|
||||||
subject(:prefill_params_array) { described_class.new(dossier, params).to_a }
|
subject(:prefill_params_array) { described_class.new(dossier, params).to_a }
|
||||||
|
|
||||||
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_communes')
|
|
||||||
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_communes')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the stable ids match the TypeDeChamp of the corresponding procedure" do
|
context "when the stable ids match the TypeDeChamp of the corresponding procedure" do
|
||||||
let(:types_de_champ_public) { [{ type: :text }, { type: :textarea }] }
|
let(:types_de_champ_public) { [{ type: :text }, { type: :textarea }] }
|
||||||
let(:type_de_champ_1) { procedure.published_revision.types_de_champ_public.first }
|
let(:type_de_champ_1) { procedure.published_revision.types_de_champ_public.first }
|
||||||
|
|
|
@ -3,22 +3,6 @@
|
||||||
RSpec.describe TypesDeChamp::PrefillCommuneTypeDeChamp do
|
RSpec.describe TypesDeChamp::PrefillCommuneTypeDeChamp do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ) { build(:type_de_champ_communes, procedure: procedure) }
|
let(:type_de_champ) { build(:type_de_champ_communes, 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
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
|
||||||
VCR.insert_cassette('api_geo_departements')
|
|
||||||
VCR.insert_cassette('api_geo_communes')
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_communes')
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'ancestors' do
|
describe 'ancestors' do
|
||||||
subject { described_class.new(type_de_champ, procedure.active_revision) }
|
subject { described_class.new(type_de_champ, procedure.active_revision) }
|
||||||
|
|
|
@ -3,12 +3,6 @@
|
||||||
RSpec.describe TypesDeChamp::PrefillDepartementTypeDeChamp, type: :model do
|
RSpec.describe TypesDeChamp::PrefillDepartementTypeDeChamp, type: :model do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ) { build(:type_de_champ_departements, procedure: procedure) }
|
let(:type_de_champ) { build(:type_de_champ_departements, 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
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'ancestors' do
|
describe 'ancestors' do
|
||||||
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
||||||
|
@ -16,7 +10,7 @@ RSpec.describe TypesDeChamp::PrefillDepartementTypeDeChamp, type: :model do
|
||||||
it { is_expected.to be_kind_of(TypesDeChamp::PrefillTypeDeChamp) }
|
it { is_expected.to be_kind_of(TypesDeChamp::PrefillTypeDeChamp) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#possible_values', vcr: { cassette_name: 'api_geo_departements' } do
|
describe '#possible_values' do
|
||||||
let(:expected_values) {
|
let(:expected_values) {
|
||||||
"Un <a href=\"https://fr.wikipedia.org/wiki/Num%C3%A9rotation_des_d%C3%A9partements_fran%C3%A7ais\" target=\"_blank\">numéro de département</a><br><a title=\"Toutes les valeurs possibles — Nouvel onglet\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"/procedures/#{procedure.path}/prefill_type_de_champs/#{type_de_champ.id}\">Voir toutes les valeurs possibles</a>"
|
"Un <a href=\"https://fr.wikipedia.org/wiki/Num%C3%A9rotation_des_d%C3%A9partements_fran%C3%A7ais\" target=\"_blank\">numéro de département</a><br><a title=\"Toutes les valeurs possibles — Nouvel onglet\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"/procedures/#{procedure.path}/prefill_type_de_champs/#{type_de_champ.id}\">Voir toutes les valeurs possibles</a>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ) { build(:type_de_champ_epci, procedure: procedure) }
|
let(:type_de_champ) { build(:type_de_champ_epci, procedure: procedure) }
|
||||||
let(:champ) { create(:champ_epci, type_de_champ: type_de_champ) }
|
let(:champ) { create(:champ_epci, type_de_champ: type_de_champ) }
|
||||||
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
|
describe 'ancestors' do
|
||||||
subject { described_class.new(type_de_champ, procedure.active_revision) }
|
subject { described_class.new(type_de_champ, procedure.active_revision) }
|
||||||
|
@ -23,16 +17,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
|
||||||
end
|
end
|
||||||
subject(:all_possible_values) { described_class.new(type_de_champ, procedure.active_revision).all_possible_values }
|
subject(:all_possible_values) { described_class.new(type_de_champ, procedure.active_revision).all_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(all_possible_values).to match(expected_values) }
|
it { expect(all_possible_values).to match(expected_values) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,16 +25,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
|
||||||
let(:epci_code) { APIGeoService.epcis(departement_code).pick(:code) }
|
let(:epci_code) { APIGeoService.epcis(departement_code).pick(:code) }
|
||||||
subject(:example_value) { described_class.new(type_de_champ, procedure.active_revision).example_value }
|
subject(:example_value) { described_class.new(type_de_champ, procedure.active_revision).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]) }
|
it { is_expected.to eq([departement_code, epci_code]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,6 @@
|
||||||
RSpec.describe TypesDeChamp::PrefillRegionTypeDeChamp, type: :model do
|
RSpec.describe TypesDeChamp::PrefillRegionTypeDeChamp, type: :model do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ) { create(:type_de_champ_regions, procedure: procedure) }
|
let(:type_de_champ) { create(:type_de_champ_regions, 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
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'ancestors' do
|
describe 'ancestors' do
|
||||||
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
||||||
|
@ -16,7 +10,7 @@ RSpec.describe TypesDeChamp::PrefillRegionTypeDeChamp, type: :model do
|
||||||
it { is_expected.to be_kind_of(TypesDeChamp::PrefillTypeDeChamp) }
|
it { is_expected.to be_kind_of(TypesDeChamp::PrefillTypeDeChamp) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#possible_values', vcr: { cassette_name: 'api_geo_regions' } do
|
describe '#possible_values' do
|
||||||
let(:expected_values) { "Un <a href=\"https://fr.wikipedia.org/wiki/R%C3%A9gion_fran%C3%A7aise\" target=\"_blank\" rel=\"noopener noreferrer\">code INSEE de région</a><br><a title=\"Toutes les valeurs possibles — Nouvel onglet\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"/procedures/#{procedure.path}/prefill_type_de_champs/#{type_de_champ.id}\">Voir toutes les valeurs possibles</a>" }
|
let(:expected_values) { "Un <a href=\"https://fr.wikipedia.org/wiki/R%C3%A9gion_fran%C3%A7aise\" target=\"_blank\" rel=\"noopener noreferrer\">code INSEE de région</a><br><a title=\"Toutes les valeurs possibles — Nouvel onglet\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"/procedures/#{procedure.path}/prefill_type_de_champs/#{type_de_champ.id}\">Voir toutes les valeurs possibles</a>" }
|
||||||
subject(:possible_values) { described_class.new(type_de_champ, procedure.active_revision).possible_values }
|
subject(:possible_values) { described_class.new(type_de_champ, procedure.active_revision).possible_values }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe TypesDeChamp::PrefillRepetitionTypeDeChamp, type: :model, vcr: { cassette_name: 'api_geo_regions' } do
|
RSpec.describe TypesDeChamp::PrefillRepetitionTypeDeChamp, type: :model do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_de_champ) { build(:type_de_champ_repetition, :with_types_de_champ, :with_region_types_de_champ, procedure: procedure) }
|
let(:type_de_champ) { build(:type_de_champ_repetition, :with_types_de_champ, :with_region_types_de_champ, procedure: procedure) }
|
||||||
let(:champ) { create(:champ_repetition, type_de_champ: type_de_champ) }
|
let(:champ) { create(:champ_repetition, type_de_champ: type_de_champ) }
|
||||||
|
@ -8,12 +8,6 @@ RSpec.describe TypesDeChamp::PrefillRepetitionTypeDeChamp, type: :model, vcr: {
|
||||||
let(:text_repetition) { prefillable_subchamps.first }
|
let(:text_repetition) { prefillable_subchamps.first }
|
||||||
let(:integer_repetition) { prefillable_subchamps.second }
|
let(:integer_repetition) { prefillable_subchamps.second }
|
||||||
let(:region_repetition) { prefillable_subchamps.third }
|
let(:region_repetition) { prefillable_subchamps.third }
|
||||||
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
|
describe 'ancestors' do
|
||||||
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
subject { described_class.build(type_de_champ, procedure.active_revision) }
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
describe APIGeoService do
|
describe APIGeoService do
|
||||||
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 'pays' do
|
describe 'pays' do
|
||||||
it 'countrie_code' do
|
it 'countrie_code' do
|
||||||
countries = JSON.parse(Rails.root.join('spec/fixtures/files/pays_dump.json').read)
|
countries = JSON.parse(Rails.root.join('spec/fixtures/files/pays_dump.json').read)
|
||||||
|
@ -26,7 +19,7 @@ describe APIGeoService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'regions', vcr: { cassette_name: 'api_geo_regions' } do
|
describe 'regions' do
|
||||||
it 'return sorted results' do
|
it 'return sorted results' do
|
||||||
expect(APIGeoService.regions.size).to eq(18)
|
expect(APIGeoService.regions.size).to eq(18)
|
||||||
expect(APIGeoService.regions.first).to eq(code: '84', name: 'Auvergne-Rhône-Alpes')
|
expect(APIGeoService.regions.first).to eq(code: '84', name: 'Auvergne-Rhône-Alpes')
|
||||||
|
@ -34,7 +27,7 @@ describe APIGeoService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'departements', vcr: { cassette_name: 'api_geo_departements' } do
|
describe 'departements' do
|
||||||
it 'return sorted results' do
|
it 'return sorted results' do
|
||||||
expect(APIGeoService.departements.size).to eq(110)
|
expect(APIGeoService.departements.size).to eq(110)
|
||||||
expect(APIGeoService.departements.first).to eq(code: '99', name: 'Etranger')
|
expect(APIGeoService.departements.first).to eq(code: '99', name: 'Etranger')
|
||||||
|
@ -43,7 +36,7 @@ describe APIGeoService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'communes', vcr: { cassette_name: 'api_geo_communes' } do
|
describe 'communes' do
|
||||||
it 'return sorted results' do
|
it 'return sorted results' do
|
||||||
expect(APIGeoService.communes('01').size).to eq(399)
|
expect(APIGeoService.communes('01').size).to eq(399)
|
||||||
expect(APIGeoService.communes('01').first).to eq(code: '01004', name: 'Ambérieu-en-Bugey', postal_code: '01500', departement_code: '01', epci_code: '240100883')
|
expect(APIGeoService.communes('01').first).to eq(code: '01004', name: 'Ambérieu-en-Bugey', postal_code: '01500', departement_code: '01', epci_code: '240100883')
|
||||||
|
@ -51,7 +44,7 @@ describe APIGeoService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'communes_by_postal_code', vcr: { cassette_name: 'api_geo_communes' } do
|
describe 'communes_by_postal_code' do
|
||||||
it 'return results' do
|
it 'return results' do
|
||||||
expect(APIGeoService.communes_by_postal_code('01500').size).to eq(8)
|
expect(APIGeoService.communes_by_postal_code('01500').size).to eq(8)
|
||||||
expect(APIGeoService.communes_by_postal_code('75019').size).to eq(2)
|
expect(APIGeoService.communes_by_postal_code('75019').size).to eq(2)
|
||||||
|
@ -63,17 +56,17 @@ describe APIGeoService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'commune_name', vcr: { cassette_name: 'api_geo_communes' } do
|
describe 'commune_name' do
|
||||||
subject { APIGeoService.commune_name('01', '01457') }
|
subject { APIGeoService.commune_name('01', '01457') }
|
||||||
it { is_expected.to eq('Vonnas') }
|
it { is_expected.to eq('Vonnas') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'commune_code', vcr: { cassette_name: 'api_geo_communes' } do
|
describe 'commune_code' do
|
||||||
subject { APIGeoService.commune_code('01', 'Vonnas') }
|
subject { APIGeoService.commune_code('01', 'Vonnas') }
|
||||||
it { is_expected.to eq('01457') }
|
it { is_expected.to eq('01457') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'epcis', vcr: { cassette_name: 'api_geo_epcis' } do
|
describe 'epcis' do
|
||||||
it 'return sorted results' do
|
it 'return sorted results' do
|
||||||
expect(APIGeoService.epcis('01').size).to eq(17)
|
expect(APIGeoService.epcis('01').size).to eq(17)
|
||||||
expect(APIGeoService.epcis('01').first).to eq(code: '200042935', name: 'CA Haut - Bugey Agglomération')
|
expect(APIGeoService.epcis('01').first).to eq(code: '200042935', name: 'CA Haut - Bugey Agglomération')
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
describe DossierProjectionService do
|
describe DossierProjectionService do
|
||||||
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 '#project' do
|
describe '#project' do
|
||||||
subject { described_class.project(dossiers_ids, fields) }
|
subject { described_class.project(dossiers_ids, fields) }
|
||||||
|
|
||||||
|
@ -54,7 +47,7 @@ describe DossierProjectionService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with commune champ', vcr: { cassette_name: 'api_geo_communes' } do
|
context 'with commune champ' do
|
||||||
let!(:procedure) { create(:procedure, types_de_champ_public: [{ type: :communes }]) }
|
let!(:procedure) { create(:procedure, types_de_champ_public: [{ type: :communes }]) }
|
||||||
let!(:dossier) { create(:dossier, procedure:) }
|
let!(:dossier) { create(:dossier, procedure:) }
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
describe ProcedureExportService do
|
describe ProcedureExportService do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs) }
|
let(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs) }
|
||||||
let(:service) { ProcedureExportService.new(procedure, procedure.dossiers) }
|
let(:service) { ProcedureExportService.new(procedure, procedure.dossiers) }
|
||||||
|
|
||||||
before do
|
describe 'to_xlsx' do
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'to_xlsx', vcr: { cassette_name: 'api_geo_all' } do
|
|
||||||
subject do
|
subject do
|
||||||
service
|
service
|
||||||
.to_xlsx
|
.to_xlsx
|
||||||
|
@ -465,7 +458,7 @@ describe ProcedureExportService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'to_zip', vcr: { cassette_name: 'api_geo_all' } do
|
describe 'to_zip' do
|
||||||
subject { service.to_zip }
|
subject { service.to_zip }
|
||||||
context 'without files' do
|
context 'without files' do
|
||||||
it 'does not raises in_batches' do
|
it 'does not raises in_batches' do
|
||||||
|
@ -529,7 +522,7 @@ describe ProcedureExportService do
|
||||||
create(:geo_area, :polygon, champ: champ_carte)
|
create(:geo_area, :polygon, champ: champ_carte)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have features', vcr: { cassette_name: 'api_geo_all' } do
|
it 'should have features' do
|
||||||
expect(subject['features'].size).to eq(1)
|
expect(subject['features'].size).to eq(1)
|
||||||
expect(properties['dossier_id']).to eq(dossier.id)
|
expect(properties['dossier_id']).to eq(dossier.id)
|
||||||
expect(properties['champ_id']).to eq(champ_carte.stable_id)
|
expect(properties['champ_id']).to eq(champ_carte.stable_id)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe 'wcag rules for usager', js: true, vcr: { cassette_name: 'api_geo_all' } do
|
describe 'wcag rules for usager', js: true do
|
||||||
let(:procedure) { create(:procedure, :published, :with_all_champs, :with_service, :for_individual) }
|
let(:procedure) { create(:procedure, :published, :with_all_champs, :with_service, :for_individual) }
|
||||||
let(:password) { 'a very complicated password' }
|
let(:password) { 'a very complicated password' }
|
||||||
let(:litteraire_user) { create(:user, password: password) }
|
let(:litteraire_user) { create(:user, password: password) }
|
||||||
|
|
|
@ -95,14 +95,7 @@ describe "procedure filters" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with a vcr cached cassette' do
|
describe 'with a vcr cached cassette' do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
scenario "should be able to find by departements with custom enum lookup", js: true do
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "should be able to find by departements with custom enum lookup", js: true, vcr: { cassette_name: 'api_geo_departements' } do
|
|
||||||
departement_champ = new_unfollow_dossier.champs.find(&:departement?)
|
departement_champ = new_unfollow_dossier.champs.find(&:departement?)
|
||||||
departement_champ.update!(value: 'Oise', external_id: '60')
|
departement_champ.update!(value: 'Oise', external_id: '60')
|
||||||
departement_champ.reload
|
departement_champ.reload
|
||||||
|
@ -117,7 +110,7 @@ describe "procedure filters" do
|
||||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should be able to find by region with custom enum lookup", js: true, vcr: { cassette_name: 'api_geo_regions' } do
|
scenario "should be able to find by region with custom enum lookup", js: true do
|
||||||
region_champ = new_unfollow_dossier.champs.find(&:region?)
|
region_champ = new_unfollow_dossier.champs.find(&:region?)
|
||||||
region_champ.update!(value: 'Bretagne', external_id: '53')
|
region_champ.update!(value: 'Bretagne', external_id: '53')
|
||||||
region_champ.reload
|
region_champ.reload
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe 'Accessing the /patron page:', vcr: { cassette_name: 'api_geo_all' } do
|
describe 'Accessing the /patron page:' do
|
||||||
scenario 'I can display a page with all form fields and UI elements' do
|
scenario 'I can display a page with all form fields and UI elements' do
|
||||||
visit patron_path
|
visit patron_path
|
||||||
expect(page).to have_text('Icônes')
|
expect(page).to have_text('Icônes')
|
||||||
|
|
|
@ -6,14 +6,7 @@ describe 'The user' do
|
||||||
let(:user_dossier) { user.dossiers.first }
|
let(:user_dossier) { user.dossiers.first }
|
||||||
let!(:dossier_to_link) { create(:dossier) }
|
let!(:dossier_to_link) { create(:dossier) }
|
||||||
|
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
scenario 'fill a dossier', js: true do
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'fill a dossier', js: true, vcr: { cassette_name: 'api_geo_all' } do
|
|
||||||
log_in(user, procedure)
|
log_in(user, procedure)
|
||||||
|
|
||||||
fill_individual
|
fill_individual
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
describe 'Prefilling a dossier (with a GET request):', js: true do
|
describe 'Prefilling a dossier (with a GET request):', js: true do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
let(:password) { 'my-s3cure-p4ssword' }
|
let(:password) { 'my-s3cure-p4ssword' }
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, opendata: true) }
|
let(:procedure) { create(:procedure, :published, opendata: true) }
|
||||||
|
@ -66,9 +64,6 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
|
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\//)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\//)
|
||||||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/etablissements.json'))
|
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/etablissements.json'))
|
||||||
|
|
||||||
|
@ -77,16 +72,6 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
|
||||||
|
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
||||||
|
|
||||||
VCR.insert_cassette('api_geo_departements')
|
|
||||||
VCR.insert_cassette('api_geo_communes')
|
|
||||||
VCR.insert_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_communes')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when authenticated' do
|
context 'when authenticated' do
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
describe 'Prefilling a dossier (with a POST request):', js: true do
|
describe 'Prefilling a dossier (with a POST request):', js: true do
|
||||||
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
|
|
||||||
|
|
||||||
let(:password) { 'my-s3cure-p4ssword' }
|
let(:password) { 'my-s3cure-p4ssword' }
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
@ -43,9 +41,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
|
||||||
let(:annuaire_education_value) { '0050009H' }
|
let(:annuaire_education_value) { '0050009H' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
|
||||||
Rails.cache.clear
|
|
||||||
|
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret_value}/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret_value}/)
|
||||||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/etablissements.json'))
|
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/etablissements.json'))
|
||||||
|
|
||||||
|
@ -54,16 +49,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
|
||||||
|
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
||||||
|
|
||||||
VCR.insert_cassette('api_geo_departements')
|
|
||||||
VCR.insert_cassette('api_geo_communes')
|
|
||||||
VCR.insert_cassette('api_geo_epcis')
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
VCR.eject_cassette('api_geo_departements')
|
|
||||||
VCR.eject_cassette('api_geo_communes')
|
|
||||||
VCR.eject_cassette('api_geo_epcis')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "the user get the URL of a prefilled orphan brouillon dossier" do
|
scenario "the user get the URL of a prefilled orphan brouillon dossier" do
|
||||||
|
|
Loading…
Reference in a new issue