Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tech: fix multiple deprecation warnings #9692

Merged
merged 10 commits into from
Nov 13, 2023
Merged
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,16 +618,12 @@ def expiration_date_reference
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?
Expand All @@ -646,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
Expand Down
1 change: 0 additions & 1 deletion config/initializers/chartkick.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Chartkick.options = {
content_for: :charts_js,
defer: true,
colors: ["#000091"],
thousands: ' ',
decimal: ','
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/cron/weekly_overview_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/export_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/lib/balancer_delivery_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/recovery/align_champ_with_dossier_revision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/recovery/revision_life_cycle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/concern/dossier_clone_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/models/dossier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/services/procedure_export_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions spec/support/shared_examples_for_jobs.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/system/users/list_dossiers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions spec/views/users/dossiers/brouillon.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down