Merge pull request #9692 from colinux/fix-deprecation-warnings

Tech: fix multiple deprecation warnings
This commit is contained in:
Colin Darie 2023-11-13 10:16:06 +00:00 committed by GitHub
commit fb318620aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 40 additions and 45 deletions

View file

@ -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)
@ -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

View file

@ -177,7 +177,8 @@ class ApplicationController < ActionController::Base
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

View file

@ -618,16 +618,12 @@ class Dossier < ApplicationRecord
end
end
def expiration_date_with_extention
[
expiration_date_reference,
conservation_extension,
procedure.duree_conservation_dossiers_dans_ds.months
].sum
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?
@ -646,7 +642,7 @@ class Dossier < ApplicationRecord
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

View file

@ -1,6 +1,5 @@
Chartkick.options = {
content_for: :charts_js,
defer: true,
colors: ["#000091"],
thousands: ' ',
decimal: ','

View file

@ -53,7 +53,7 @@ RSpec.describe Manager::AdministrateurConfirmationsController, type: :controller
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 @@ RSpec.describe Manager::AdministrateurConfirmationsController, type: :controller
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 }

View file

@ -32,7 +32,7 @@ RSpec.describe Cron::WeeklyOverviewJob, type: :job do
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

View file

@ -23,7 +23,7 @@ describe ExportJob do
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

View file

@ -35,7 +35,7 @@ RSpec.describe BalancerDeliveryMethod do
end
def deliver!(mail)
Mail::CheckDeliveryParams.check(mail)
Mail::SmtpEnvelope.new(mail)
self.class.deliveries << mail
end
end

View file

@ -33,7 +33,7 @@ describe Recovery::AlignChampWithDossierRevision do
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 @@ describe Recovery::AlignChampWithDossierRevision do
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

View file

@ -30,7 +30,7 @@ describe 'Recovery::Revision::LifeCycle' do
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

View file

@ -385,7 +385,7 @@ RSpec.describe DossierCloneConcern do
procedure.publish_revision!
end
it 'works' do
expect { subject }.not_to raise_error(ActiveRecord::InvalidForeignKey)
expect { subject }.not_to raise_error
end
end
end

View file

@ -93,8 +93,8 @@ describe Dossier, type: :model do
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 @@ describe Dossier, type: :model do
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 @@ describe Dossier, type: :model do
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

View file

@ -86,7 +86,7 @@ RSpec.configure do |config|
ActionMailer::Base.deliveries.clear
ActiveStorage::Current.host = 'http://test.host'
ActiveStorage::Current.url_options = { host: 'http://test.host' }
Geocoder.configure(lookup: :test)
end

View file

@ -489,7 +489,7 @@ describe ProcedureExportService do
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

View file

@ -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 @@ RSpec.shared_examples 'a job retrying transient errors' do |job_class = describe
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

View file

@ -263,8 +263,8 @@ describe 'user access to the list of their dossiers', js: true do
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

View file

@ -7,8 +7,7 @@ describe 'users/dossiers/brouillon', type: :view do
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 }