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).
This commit is contained in:
Pierre de La Morinerie 2021-02-04 12:59:10 +01:00
parent 0d94eacf32
commit 4ad9adc510

View file

@ -227,8 +227,8 @@ class Dossier < ApplicationRecord
user: []) user: [])
} }
scope :with_notifiable_procedure, -> (notify_on_closed: false) do scope :with_notifiable_procedure, -> (opts = { notify_on_closed: false }) do
states = notify_on_closed ? [:publiee, :close, :depubliee] : [:publiee, :depubliee] states = opts[:notify_on_closed] ? [:publiee, :close, :depubliee] : [:publiee, :depubliee]
joins(:procedure) joins(:procedure)
.where(procedures: { aasm_state: states }) .where(procedures: { aasm_state: states })
end end