From b204fe74a42c269330e9b7bdb8bb70777809aa74 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Feb 2021 12:45:35 +0100 Subject: [PATCH 1/4] gems: update zip_tricks and zipline This fixes a Ruby 2.7 deprecation warning: > /ruby/2.7.0/gems/zip_tricks-5.3.1/lib/zip_tricks/streamer.rb:340: warning: The called method `write_deflated_file' is defined here --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d8d3d540..b54bf1331 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -792,9 +792,9 @@ GEM xray-rails (0.3.2) rails (>= 3.1.0) zeitwerk (2.4.2) - zip_tricks (5.3.1) - zipline (1.2.1) - rails (>= 3.2.1, < 6.1) + zip_tricks (5.5.0) + zipline (1.3.0) + actionpack (>= 3.2.1, < 7.0) zip_tricks (>= 4.2.1, < 6.0) zxcvbn-ruby (1.1.0) From 0d94eacf32d5a2e89415fed545d34697e667925e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Feb 2021 12:38:11 +0100 Subject: [PATCH 2/4] spec: fix Ruby 2.7 arguments passing --- spec/support/feature_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index e4f26d2f1..56347bbfa 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -71,7 +71,7 @@ module FeatureHelpers # Add a new type de champ in the procedure editor def add_champ(options = {}) - add_champs(options) + add_champs(**options) end # Add several new type de champ in the procedure editor From 4ad9adc5105dff71c5acd3484df60e6943bce0a2 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Feb 2021 12:59:10 +0100 Subject: [PATCH 3/4] models: fix Ruby 2.7 arguments passing Arguments to an ActiveRecord scope will always been passed as a Dictionnary. Thus `Dossier.with_notifiable_procedure(notify_on_closed: true)` will trigger a Ruby 2.7 warning: > /ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:412: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call Fix the issue by always expecting a Dictionary (rather than keyword arguments). --- app/models/dossier.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index a763570c1..59ea1f07a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -227,8 +227,8 @@ class Dossier < ApplicationRecord user: []) } - scope :with_notifiable_procedure, -> (notify_on_closed: false) do - states = notify_on_closed ? [:publiee, :close, :depubliee] : [:publiee, :depubliee] + scope :with_notifiable_procedure, -> (opts = { notify_on_closed: false }) do + states = opts[:notify_on_closed] ? [:publiee, :close, :depubliee] : [:publiee, :depubliee] joins(:procedure) .where(procedures: { aasm_state: states }) end From 2d1c50917f09cd7a5cdb1606b1eee94f62b9bac8 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Feb 2021 13:03:04 +0100 Subject: [PATCH 4/4] mailers: fix Ruby 2.7 arguments passing --- app/mailers/dossier_mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 1d340c32b..285802797 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -150,7 +150,7 @@ class DossierMailer < ApplicationMailer if interpolations[:state] mailer_scope = self.class.mailer_name.tr('/', '.') state = interpolations[:state].in?(Dossier::TERMINE) ? 'termine' : interpolations[:state] - I18n.t("subject_#{state}", interpolations.merge(scope: [mailer_scope, action_name])) + I18n.t("subject_#{state}", **interpolations.merge(scope: [mailer_scope, action_name])) else super end