chore(spec): remove memory store cache from tests

This commit is contained in:
Paul Chavard 2023-04-13 13:10:23 +02:00
parent 98caf41a36
commit 5abb6a8f12
29 changed files with 3976 additions and 398 deletions

View file

@ -15,18 +15,15 @@ describe Administrateurs::ProceduresController, type: :controller do
let(:zone_ids) { [zone.id] }
let(:tags) { "[\"planete\",\"environnement\"]" }
describe '#apercu', vcr: { cassette_name: 'api_geo_all' } do
describe '#apercu' do
render_views
let(:procedure) { create(:procedure, :with_all_champs) }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
subject { get :apercu, params: { id: procedure.id } }
before do
sign_in(admin.user)
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
end
it do

View file

@ -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(: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 }
describe 'GET index (with bearer token)' do
@ -265,7 +258,7 @@ describe API::V1::DossiersController do
end
end
describe 'departement', vcr: { cassette_name: 'api_geo_departements' } do
describe 'departement' do
let(:procedure) { create(:procedure, :with_departement, administrateur: admin) }
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure: procedure) }

View file

@ -11,8 +11,6 @@ describe API::V2::GraphqlController do
let(:dossiers) { [dossier] }
let(:instructeur) { create(:instructeur, followed_dossiers: dossiers) }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
def compute_checksum_in_chunks(io)
Digest::MD5.new.tap do |checksum|
while (chunk = io.read(5.megabytes))
@ -40,12 +38,7 @@ describe API::V2::GraphqlController do
blob
end
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
instructeur.assign_to_procedure(procedure)
end
before { instructeur.assign_to_procedure(procedure) }
let(:query) do
"{
@ -407,7 +400,7 @@ describe API::V2::GraphqlController do
dossier
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(:query) do
"{

View file

@ -193,7 +193,7 @@ describe API::V2::GraphqlController do
end
end
context 'getDemarcheDescriptor', vcr: { cassette_name: 'api_geo_regions' } do
context 'getDemarcheDescriptor' do
let(:operation_name) { 'getDemarcheDescriptor' }
let(:types_de_champ_public) { [{ type: :text }, { type: :piece_justificative }, { type: :regions }] }

File diff suppressed because one or more lines are too long

View file

@ -26,7 +26,7 @@ RSpec.describe Types::DossierType, type: :graphql do
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(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) }
let(:query) { DOSSIER_WITH_CHAMPS_QUERY }
@ -48,13 +48,7 @@ RSpec.describe Types::DossierType, type: :graphql do
}
end
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
dossier.champs_public.second.update(data: address)
end
before { dossier.champs_public.second.update(data: address) }
it do
expect(data[:dossier][:champs][0][:__typename]).to eq "CommuneChamp"

View file

@ -1,6 +1,4 @@
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(:procedure) { create(:procedure, :with_all_champs) }
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) }
@ -11,15 +9,10 @@ describe '20220705164551_remove_unused_champs' do
rake_task.invoke
end
before do
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
before { champ_repetition.champs.first.update(type_de_champ: create(:type_de_champ)) }
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
expect(Champ.where(dossier: dossier).count).to eq(40)
run_task

View file

@ -146,18 +146,11 @@ describe Champ do
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(:champ) { type_de_champ.champ.build(value: value) }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
champ.save
end
before { champ.save }
context 'when type_de_champ is text' do
let(:value) { '123' }

View file

@ -1,16 +1,9 @@
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_postal) { '63290' }
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) }
it 'with code_postal' do

View file

@ -1,12 +1,5 @@
describe Champs::DepartementChamp, 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', vcr: { cassette_name: 'api_geo_departements' } do
describe 'validations' do
describe 'external link' do
subject { build(:champ_departements, external_id: external_id) }
@ -66,7 +59,7 @@ describe Champs::DepartementChamp, type: :model do
end
end
describe 'value', vcr: { cassette_name: 'api_geo_departements' } do
describe 'value' do
let(:champ) { described_class.new }
it 'with code having 2 chars' do

View file

@ -1,13 +1,6 @@
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 'code_departement', vcr: { cassette_name: 'api_geo_departements' } do
describe 'code_departement' do
subject { build(:champ_epci, code_departement: code_departement) }
context 'when nil' do
@ -41,18 +34,10 @@ describe Champs::EpciChamp, type: :model do
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 }
@ -95,18 +80,10 @@ describe Champs::EpciChamp, type: :model do
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 }
@ -154,7 +131,7 @@ describe Champs::EpciChamp, type: :model do
end
end
describe 'value', vcr: { cassette_name: 'api_geo_epcis' } do
describe 'value' do
let(:champ) { described_class.new }
it 'with departement and code' do
champ.code_departement = '01'

View file

@ -1,12 +1,5 @@
describe Champs::RegionChamp, 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', vcr: { cassette_name: 'api_geo_regions' } do
describe 'validations' do
describe 'external link' do
subject { build(:champ_regions, external_id: external_id) }
@ -66,7 +59,7 @@ describe Champs::RegionChamp, type: :model do
end
end
describe 'value', vcr: { cassette_name: 'api_geo_regions' } do
describe 'value' do
let(:champ) { described_class.new }
it 'with code' do

View file

@ -1573,7 +1573,7 @@ describe Dossier do
end
end
describe "champs_for_export", vcr: { cassette_name: 'api_geo_communes' } do
describe "champs_for_export" 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(: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
describe "#destroy", vcr: { cassette_name: 'api_geo_all' } 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 "#destroy" do
let(:procedure) { create(:procedure, :with_all_champs, :with_all_annotations) }
let(:transfer) { create(:dossier_transfer) }
let(:dossier) { create(:dossier, :with_populated_champs, :with_populated_annotations, transfer: transfer, procedure: procedure) }

View file

@ -86,7 +86,7 @@ RSpec.describe PrefillDescription, type: :model do
end
end
describe '#prefill_link', vcr: { cassette_name: 'api_geo_regions' } do
describe '#prefill_link' do
let(:procedure) { create(: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) }
@ -95,23 +95,10 @@ RSpec.describe PrefillDescription, type: :model do
let(:region_repetition) { prefillable_subchamps.third }
let(:prefill_description) { described_class.new(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')
prefill_description.update(selected_type_de_champ_ids: [type_de_champ_text.id, type_de_champ_epci.id, type_de_champ_repetition.id])
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
expect(prefill_description.prefill_link).to eq(
CGI.unescape(
@ -126,7 +113,7 @@ RSpec.describe PrefillDescription, type: :model do
end
end
describe '#prefill_query', vcr: { cassette_name: 'api_geo_regions' } do
describe '#prefill_query' do
let(:procedure) { create(: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) }
@ -144,23 +131,10 @@ RSpec.describe PrefillDescription, type: :model do
TEXT
end
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_text.id, type_de_champ_epci.id, type_de_champ_repetition.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

View file

@ -1,7 +1,5 @@
RSpec.describe PrefillParams do
describe "#to_a", vcr: { cassette_name: 'api_geo_all' } do
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
describe "#to_a" do
let(:procedure) { create(:procedure, :published, types_de_champ_public:, types_de_champ_private:) }
let(:dossier) { create(:dossier, :brouillon, procedure: procedure) }
let(:types_de_champ_public) { [] }
@ -9,23 +7,6 @@ RSpec.describe PrefillParams do
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
let(:types_de_champ_public) { [{ type: :text }, { type: :textarea }] }
let(:type_de_champ_1) { procedure.published_revision.types_de_champ_public.first }

View file

@ -3,22 +3,6 @@
RSpec.describe TypesDeChamp::PrefillCommuneTypeDeChamp do
let(:procedure) { create(: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
subject { described_class.new(type_de_champ, procedure.active_revision) }

View file

@ -3,12 +3,6 @@
RSpec.describe TypesDeChamp::PrefillDepartementTypeDeChamp, type: :model do
let(:procedure) { create(: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
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) }
end
describe '#possible_values', vcr: { cassette_name: 'api_geo_departements' } do
describe '#possible_values' do
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>"
}

View file

@ -4,12 +4,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
let(:procedure) { create(:procedure) }
let(:type_de_champ) { build(:type_de_champ_epci, procedure: procedure) }
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
subject { described_class.new(type_de_champ, procedure.active_revision) }
@ -23,16 +17,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
end
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) }
end
@ -41,16 +25,6 @@ RSpec.describe TypesDeChamp::PrefillEpciTypeDeChamp do
let(:epci_code) { APIGeoService.epcis(departement_code).pick(:code) }
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]) }
end

View file

@ -3,12 +3,6 @@
RSpec.describe TypesDeChamp::PrefillRegionTypeDeChamp, type: :model do
let(:procedure) { create(: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
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) }
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>" }
subject(:possible_values) { described_class.new(type_de_champ, procedure.active_revision).possible_values }

View file

@ -1,6 +1,6 @@
# 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(: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) }
@ -8,12 +8,6 @@ RSpec.describe TypesDeChamp::PrefillRepetitionTypeDeChamp, type: :model, vcr: {
let(:text_repetition) { prefillable_subchamps.first }
let(:integer_repetition) { prefillable_subchamps.second }
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
subject { described_class.build(type_de_champ, procedure.active_revision) }

View file

@ -1,11 +1,4 @@
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
it 'countrie_code' do
countries = JSON.parse(Rails.root.join('spec/fixtures/files/pays_dump.json').read)
@ -26,7 +19,7 @@ describe APIGeoService do
end
end
describe 'regions', vcr: { cassette_name: 'api_geo_regions' } do
describe 'regions' do
it 'return sorted results' do
expect(APIGeoService.regions.size).to eq(18)
expect(APIGeoService.regions.first).to eq(code: '84', name: 'Auvergne-Rhône-Alpes')
@ -34,7 +27,7 @@ describe APIGeoService do
end
end
describe 'departements', vcr: { cassette_name: 'api_geo_departements' } do
describe 'departements' do
it 'return sorted results' do
expect(APIGeoService.departements.size).to eq(110)
expect(APIGeoService.departements.first).to eq(code: '99', name: 'Etranger')
@ -43,7 +36,7 @@ describe APIGeoService do
end
end
describe 'communes', vcr: { cassette_name: 'api_geo_communes' } do
describe 'communes' do
it 'return sorted results' do
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')
@ -51,7 +44,7 @@ describe APIGeoService do
end
end
describe 'communes_by_postal_code', vcr: { cassette_name: 'api_geo_communes' } do
describe 'communes_by_postal_code' do
it 'return results' do
expect(APIGeoService.communes_by_postal_code('01500').size).to eq(8)
expect(APIGeoService.communes_by_postal_code('75019').size).to eq(2)
@ -63,17 +56,17 @@ describe APIGeoService do
end
end
describe 'commune_name', vcr: { cassette_name: 'api_geo_communes' } do
describe 'commune_name' do
subject { APIGeoService.commune_name('01', '01457') }
it { is_expected.to eq('Vonnas') }
end
describe 'commune_code', vcr: { cassette_name: 'api_geo_communes' } do
describe 'commune_code' do
subject { APIGeoService.commune_code('01', 'Vonnas') }
it { is_expected.to eq('01457') }
end
describe 'epcis', vcr: { cassette_name: 'api_geo_epcis' } do
describe 'epcis' do
it 'return sorted results' do
expect(APIGeoService.epcis('01').size).to eq(17)
expect(APIGeoService.epcis('01').first).to eq(code: '200042935', name: 'CA Haut - Bugey Agglomération')

View file

@ -1,11 +1,4 @@
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
subject { described_class.project(dossiers_ids, fields) }
@ -54,7 +47,7 @@ describe DossierProjectionService do
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!(:dossier) { create(:dossier, procedure:) }

View file

@ -1,17 +1,10 @@
require 'csv'
describe ProcedureExportService do
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
let(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs) }
let(:service) { ProcedureExportService.new(procedure, procedure.dossiers) }
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
end
describe 'to_xlsx', vcr: { cassette_name: 'api_geo_all' } do
describe 'to_xlsx' do
subject do
service
.to_xlsx
@ -465,7 +458,7 @@ describe ProcedureExportService do
end
end
describe 'to_zip', vcr: { cassette_name: 'api_geo_all' } do
describe 'to_zip' do
subject { service.to_zip }
context 'without files' do
it 'does not raises in_batches' do
@ -529,7 +522,7 @@ describe ProcedureExportService do
create(:geo_area, :polygon, champ: champ_carte)
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(properties['dossier_id']).to eq(dossier.id)
expect(properties['champ_id']).to eq(champ_carte.stable_id)

View file

@ -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(:password) { 'a very complicated password' }
let(:litteraire_user) { create(:user, password: password) }

View file

@ -95,14 +95,7 @@ describe "procedure filters" do
end
describe 'with a vcr cached cassette' 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
scenario "should be able to find by departements with custom enum lookup", js: true, vcr: { cassette_name: 'api_geo_departements' } do
scenario "should be able to find by departements with custom enum lookup", js: true do
departement_champ = new_unfollow_dossier.champs.find(&:departement?)
departement_champ.update!(value: 'Oise', external_id: '60')
departement_champ.reload
@ -117,7 +110,7 @@ describe "procedure filters" do
expect(page).to have_link(new_unfollow_dossier.id.to_s)
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.update!(value: 'Bretagne', external_id: '53')
region_champ.reload

View file

@ -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
visit patron_path
expect(page).to have_text('Icônes')

View file

@ -6,14 +6,7 @@ describe 'The user' do
let(:user_dossier) { user.dossiers.first }
let!(:dossier_to_link) { create(:dossier) }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
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
scenario 'fill a dossier', js: true do
log_in(user, procedure)
fill_individual

View file

@ -1,6 +1,4 @@
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(:procedure) { create(:procedure, :published, opendata: true) }
@ -66,9 +64,6 @@ describe 'Prefilling a dossier (with a GET request):', js: true 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\//)
.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\//)
.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
context 'when authenticated' do

View file

@ -1,6 +1,4 @@
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(:procedure) { create(:procedure, :published) }
@ -43,9 +41,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
let(:annuaire_education_value) { '0050009H' }
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}/)
.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\//)
.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
scenario "the user get the URL of a prefilled orphan brouillon dossier" do