From c38dac789d85d501e615b2ce66f8ec40232d73e7 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 17:24:49 +0100 Subject: [PATCH 01/10] test: fix deprecation warning, a selector matcher must be a string or symbol --- spec/system/users/list_dossiers_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/users/list_dossiers_spec.rb b/spec/system/users/list_dossiers_spec.rb index bba0afdac67..3f8938f9bcb 100644 --- a/spec/system/users/list_dossiers_spec.rb +++ b/spec/system/users/list_dossiers_spec.rb @@ -263,8 +263,8 @@ it "can be filtered by procedure and display the result - no item" do select dossier_brouillon.procedure.libelle, from: 'procedure_id' - expect(page).not_to have_link(dossier_en_construction.id) - expect(page).not_to have_link(dossier_with_champs.id) + expect(page).not_to have_link(String(dossier_en_construction.id)) + expect(page).not_to have_link(String(dossier_with_champs.id)) expect(page).to have_content("Résultat de la recherche pour « #{dossier_en_construction.champs_public.first.value} » et pour la procédure « #{dossier_brouillon.procedure.libelle} » ") expect(page).to have_text("Aucun dossier") end From edb47d94f70298d6eabfdd7165203fb29eed649b Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 17:27:55 +0100 Subject: [PATCH 02/10] test: fix not_to raise_error(SpecificErrorClass) false positive risk --- spec/jobs/cron/weekly_overview_job_spec.rb | 2 +- spec/jobs/export_job_spec.rb | 2 +- spec/lib/recovery/align_champ_with_dossier_revision_spec.rb | 4 ++-- spec/lib/recovery/revision_life_cycle_spec.rb | 2 +- spec/models/concern/dossier_clone_concern_spec.rb | 2 +- spec/services/procedure_export_service_spec.rb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/jobs/cron/weekly_overview_job_spec.rb b/spec/jobs/cron/weekly_overview_job_spec.rb index e6fd7e254be..9e1041e5a12 100644 --- a/spec/jobs/cron/weekly_overview_job_spec.rb +++ b/spec/jobs/cron/weekly_overview_job_spec.rb @@ -32,7 +32,7 @@ end it { expect(InstructeurMailer).to have_received(:last_week_overview).with(instructeur) } - it { expect { run_job }.not_to raise_error(NoMethodError) } + it { expect { run_job }.not_to raise_error } end end diff --git a/spec/jobs/export_job_spec.rb b/spec/jobs/export_job_spec.rb index a6e26c6a753..81893d4c4ef 100644 --- a/spec/jobs/export_job_spec.rb +++ b/spec/jobs/export_job_spec.rb @@ -23,7 +23,7 @@ let(:format) { :zip } it 'does not try to identify file' do - expect { subject }.not_to raise_error(ActiveStorage::FileNotFoundError) + expect { subject }.not_to raise_error end end end diff --git a/spec/lib/recovery/align_champ_with_dossier_revision_spec.rb b/spec/lib/recovery/align_champ_with_dossier_revision_spec.rb index 6a10aabf528..67f96678756 100644 --- a/spec/lib/recovery/align_champ_with_dossier_revision_spec.rb +++ b/spec/lib/recovery/align_champ_with_dossier_revision_spec.rb @@ -33,7 +33,7 @@ expect(fixer.logs.size).to eq(1) expect(fixer.logs.first.fetch(:status)).to eq(:updated) - expect { DossierPreloader.load_one(bad_dossier) }.not_to raise_error(ArgumentError) + expect { DossierPreloader.load_one(bad_dossier) }.not_to raise_error expect(bad_dossier.champs.size).to eq(2) expect(bad_dossier.champs_public.size).to eq(2) end @@ -60,7 +60,7 @@ expect(fixer.logs.size).to eq(1) expect(fixer.logs.first.fetch(:status)).to eq(:not_found) - expect { DossierPreloader.load_one(bad_dossier) }.not_to raise_error(ArgumentError) + expect { DossierPreloader.load_one(bad_dossier) }.not_to raise_error expect(bad_dossier.champs.size).to eq(1) expect(bad_dossier.champs_public.size).to eq(1) end diff --git a/spec/lib/recovery/revision_life_cycle_spec.rb b/spec/lib/recovery/revision_life_cycle_spec.rb index 4ea60b5b449..eb4c5e966dd 100644 --- a/spec/lib/recovery/revision_life_cycle_spec.rb +++ b/spec/lib/recovery/revision_life_cycle_spec.rb @@ -30,7 +30,7 @@ def cleanup_export_file expect(dossier.champs_public.size).to eq(1) expect(dossier.champs.size).to eq(2) importer.load - expect { DossierPreloader.load_one(dossier) }.not_to raise_error(ArgumentError) + expect { DossierPreloader.load_one(dossier) }.not_to raise_error expect(dossier.champs_public.size).to eq(2) end end diff --git a/spec/models/concern/dossier_clone_concern_spec.rb b/spec/models/concern/dossier_clone_concern_spec.rb index 8bd9cbfd4aa..b7922de6127 100644 --- a/spec/models/concern/dossier_clone_concern_spec.rb +++ b/spec/models/concern/dossier_clone_concern_spec.rb @@ -385,7 +385,7 @@ procedure.publish_revision! end it 'works' do - expect { subject }.not_to raise_error(ActiveRecord::InvalidForeignKey) + expect { subject }.not_to raise_error end end end diff --git a/spec/services/procedure_export_service_spec.rb b/spec/services/procedure_export_service_spec.rb index 1d3f7c6e9ab..0cdc536ffd1 100644 --- a/spec/services/procedure_export_service_spec.rb +++ b/spec/services/procedure_export_service_spec.rb @@ -489,7 +489,7 @@ subject { service.to_zip } context 'without files' do it 'does not raises in_batches' do - expect { subject }.not_to raise_error(NoMethodError) + expect { subject }.not_to raise_error end it 'returns an empty blob' do From 610b808d324428b86452405687824cdd27610ab9 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 17:43:20 +0100 Subject: [PATCH 03/10] test: fix deprecated any_instance and stub old syntax --- .../manager/administrateur_confirmations_controller_spec.rb | 4 ++-- spec/views/users/dossiers/brouillon.html.haml_spec.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/controllers/manager/administrateur_confirmations_controller_spec.rb b/spec/controllers/manager/administrateur_confirmations_controller_spec.rb index ef629eef167..32a0b65d4c5 100644 --- a/spec/controllers/manager/administrateur_confirmations_controller_spec.rb +++ b/spec/controllers/manager/administrateur_confirmations_controller_spec.rb @@ -53,7 +53,7 @@ describe 'edge cases' do context 'when the environment is development' do - before { Rails.env.stub(development?: true) } + before { allow(Rails.env).to receive(:development?).and_return(true) } context 'when the current admin is the inviter' do before { sign_in inviter_super_admin } @@ -130,7 +130,7 @@ describe 'edge cases' do context 'when the environment is development' do - before { Rails.env.stub(development?: true) } + before { allow(Rails.env).to receive(:development?).and_return(true) } context 'when the current admin is the inviter' do before { sign_in inviter_super_admin } diff --git a/spec/views/users/dossiers/brouillon.html.haml_spec.rb b/spec/views/users/dossiers/brouillon.html.haml_spec.rb index ea30edd23d3..baf50c95f3b 100644 --- a/spec/views/users/dossiers/brouillon.html.haml_spec.rb +++ b/spec/views/users/dossiers/brouillon.html.haml_spec.rb @@ -7,8 +7,7 @@ before do sign_in dossier.user assign(:dossier, dossier) - # allow(view) doesn't work because method is called inside partial - ActionView::Base.any_instance.stub(:administrateur_signed_in?).and_return(profile == :administrateur) + allow_any_instance_of(ActionView::Base).to receive(:administrateur_signed_in?).and_return(profile == :administrateur) end subject! { render } From 65feaa37e372be5222e3ae1b6fd9f373a6b05ce6 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 17:46:54 +0100 Subject: [PATCH 04/10] test: fix deprecated Mail::CheckDeliveryParams.check syntax --- spec/lib/balancer_delivery_method_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/balancer_delivery_method_spec.rb b/spec/lib/balancer_delivery_method_spec.rb index bf5e39b527d..7fb2495beba 100644 --- a/spec/lib/balancer_delivery_method_spec.rb +++ b/spec/lib/balancer_delivery_method_spec.rb @@ -35,7 +35,7 @@ def initialize(values) end def deliver!(mail) - Mail::CheckDeliveryParams.check(mail) + Mail::SmtpEnvelope.new(mail) self.class.deliveries << mail end end From 148611d595e77e93544e590c0236f29d3f8ca9a5 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 13:23:35 +0100 Subject: [PATCH 05/10] fix(dossier): rails 7 deprecation warning about sum of non numeric values --- app/models/dossier.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 178acd8e634..cc55526c10c 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -619,11 +619,7 @@ def expiration_date_reference end def expiration_date_with_extention - [ - expiration_date_reference, - conservation_extension, - procedure.duree_conservation_dossiers_dans_ds.months - ].sum + expiration_date_reference + conservation_extension + procedure.duree_conservation_dossiers_dans_ds.months end def expiration_notification_date From 8326cf080e9c3ee13ba16373675bafc883a5542a Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 13:24:37 +0100 Subject: [PATCH 06/10] fix: typo in method name extention => extension --- app/models/dossier.rb | 6 +++--- spec/models/dossier_spec.rb | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index cc55526c10c..7aae04a2849 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -618,12 +618,12 @@ def expiration_date_reference end end - def expiration_date_with_extention + def expiration_date_with_extension expiration_date_reference + conservation_extension + procedure.duree_conservation_dossiers_dans_ds.months end def expiration_notification_date - expiration_date_with_extention - REMAINING_WEEKS_BEFORE_EXPIRATION.weeks + expiration_date_with_extension - REMAINING_WEEKS_BEFORE_EXPIRATION.weeks end def close_to_expiration? @@ -642,7 +642,7 @@ def after_notification_expiration_date end def expiration_date - after_notification_expiration_date.presence || expiration_date_with_extention + after_notification_expiration_date.presence || expiration_date_with_extension end def duration_after_notice diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 9836bcf105a..60307e87189 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -93,8 +93,8 @@ expect(expiring_dossier.close_to_expiration?).to be_falsey expect(expiring_dossier_with_notification.close_to_expiration?).to be_falsey - expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extention) - expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extention) + expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extension) + expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extension) end end @@ -144,8 +144,8 @@ expect(expiring_dossier.close_to_expiration?).to be_falsey expect(expiring_dossier_with_notification.close_to_expiration?).to be_falsey - expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extention) - expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extention) + expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extension) + expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extension) end end @@ -204,8 +204,8 @@ expect(expiring_dossier.close_to_expiration?).to be_falsey expect(expiring_dossier_with_notification.close_to_expiration?).to be_falsey - expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extention) - expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extention) + expect(expiring_dossier.expiration_date).to eq(expiring_dossier.expiration_date_with_extension) + expect(expiring_dossier_with_notification.expiration_date).to eq(expiring_dossier_with_notification.expiration_date_with_extension) end end From 25dfbe50855f40d3302731b7fb98774b7f480032 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 13:30:43 +0100 Subject: [PATCH 07/10] chore: fix ActiveStorage::Current.host deprecation warning --- app/controllers/application_controller.rb | 3 ++- spec/rails_helper.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eb4dc8d81dd..05291ef1a37 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -177,7 +177,8 @@ def configure_permitted_parameters private def set_active_storage_host - ActiveStorage::Current.host = request.base_url + ActiveStorage::Current.url_options ||= {} + ActiveStorage::Current.url_options[:host] = request.base_url end def setup_javascript_settings diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a45eeceb5be..8ccfede3598 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -86,7 +86,7 @@ ActionMailer::Base.deliveries.clear - ActiveStorage::Current.host = 'http://test.host' + ActiveStorage::Current.url_options = { host: 'http://test.host' } Geocoder.configure(lookup: :test) end From baecdd5cbd365564bad0e8e2aa06683f4c92f886 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 13:43:38 +0100 Subject: [PATCH 08/10] chore(bundle): update groupdate to fix ActiveRecord::Base.default_timezone deprecation warning --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28f64329f69..40e092458b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -293,8 +293,8 @@ GEM bundler (>= 1.14) graphql (>= 1.10, < 3.0) thor (>= 0.19, < 2.0) - groupdate (5.2.2) - activesupport (>= 5) + groupdate (6.4.0) + activesupport (>= 6.1) haml (6.0.5) temple (>= 0.8.2) thor From 92661d074d6ae8beb95e00fc006315b93c3370b8 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 13:48:46 +0100 Subject: [PATCH 09/10] chore(bundle): update chartkick to fix defer deprecation warning and v5 like JS counterpart --- Gemfile.lock | 2 +- config/initializers/chartkick.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 40e092458b7..4bd0a6c425a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -161,7 +161,7 @@ GEM nokogiri (~> 1.10, >= 1.10.4) rubyzip (>= 1.3.0, < 3) charlock_holmes (0.7.7) - chartkick (4.1.3) + chartkick (5.0.4) choice (0.2.0) chunky_png (1.4.0) clamav-client (3.2.0) diff --git a/config/initializers/chartkick.rb b/config/initializers/chartkick.rb index 4e07d45e59b..4f44c1a38d3 100644 --- a/config/initializers/chartkick.rb +++ b/config/initializers/chartkick.rb @@ -1,6 +1,5 @@ Chartkick.options = { content_for: :charts_js, - defer: true, colors: ["#000091"], thousands: ' ', decimal: ',' From e591851b799a01b559275e94e6317e8b8b24b354 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 14:24:28 +0100 Subject: [PATCH 10/10] test: fix warning about classes already defined by another spec --- spec/support/shared_examples_for_jobs.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/support/shared_examples_for_jobs.rb b/spec/support/shared_examples_for_jobs.rb index f30a6776946..3343073699d 100644 --- a/spec/support/shared_examples_for_jobs.rb +++ b/spec/support/shared_examples_for_jobs.rb @@ -1,11 +1,17 @@ RSpec.shared_examples 'a job retrying transient errors' do |job_class = described_class| - context 'when a transient network error is raised' do - ExconErrorJob = Class.new(job_class) do - def perform - raise Excon::Error::InternalServerError, 'msg' - end + ExconErrorJob = Class.new(job_class) do + def perform + raise Excon::Error::InternalServerError, 'msg' + end + end if !defined?(ExconErrorJob) + + StandardErrorJob = Class.new(job_class) do + def perform + raise StandardError end + end if !defined?(StandardErrorJob) + context 'when a transient network error is raised' do it 'makes 5 attempts before raising the exception up' do assert_performed_jobs 5 do ExconErrorJob.perform_later rescue Excon::Error::InternalServerError @@ -14,12 +20,6 @@ def perform end context 'when another type of error is raised' do - StandardErrorJob = Class.new(job_class) do - def perform - raise StandardError - end - end - it 'makes only 1 attempt before raising the exception up' do assert_performed_jobs 1 do StandardErrorJob.perform_later rescue StandardError