Fix some keyword args for ruby 3 compatibility

This commit is contained in:
Benjamin Neff 2022-07-21 00:04:58 +02:00
parent 93c69c4d42
commit 022f367692
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
8 changed files with 17 additions and 14 deletions

View file

@ -20,11 +20,11 @@ module NotificationsHelper
opts.merge!(opts_for_birthday(note))
end
end
translation(target_type, opts)
translation(target_type, **opts)
end
def translation(target_type, opts = {})
t("#{target_type}", opts).html_safe
def translation(target_type, **kwargs)
t(target_type, **kwargs).html_safe # rubocop:disable Rails/OutputSafety
end
def opts_for_post(post)

View file

@ -26,7 +26,7 @@ class ReportMailer < ApplicationMailer
private
def format(resource)
body = I18n.t("notifier.report_email.body", resource)
body = I18n.t("notifier.report_email.body", **resource)
mail(to: resource[:email], subject: I18n.t("notifier.report_email.subject", type: resource[:type])) do |format|
format.html { render "notifier/plain_markdown_email", locals: {body: body} }
format.text { render "notifier/plain_markdown_email", locals: {body: body} }

View file

@ -20,8 +20,12 @@ class BasePresenter
@current_user = curr_user
end
def method_missing(method, *args)
@presentable.public_send(method, *args)
def respond_to_missing?(method, include_private=false)
@presentable.respond_to?(method) || super
end
def method_missing(method, *args, **kwargs) # rubocop:disable Lint/MissingSuper
@presentable.public_send(method, *args, **kwargs)
end
class NilPresenter

View file

@ -20,7 +20,7 @@ module ApplicationCukeHelpers
def flash_message(opts={})
selector = opts.delete(:selector)
selector &&= ".alert-#{selector}"
find(selector || ".flash-message", {match: :first}.merge(opts))
find(selector || ".flash-message", **{match: :first}.merge(opts))
end
def confirm_form_validation_error(element)

View file

@ -63,7 +63,7 @@ module NavigationHelpers
if path.is_a?(Hash)
visit(path[:path])
await_elem = path[:special_elem]
find(await_elem.delete(:selector), await_elem)
find(await_elem.delete(:selector), **await_elem)
else
visit(path)
end

View file

@ -71,7 +71,7 @@ describe Retraction do
expect(Workers::DeferredRetraction).to receive(:perform_async).with(
local_luke.id, "Retraction", federation_retraction.to_h.deep_stringify_keys, [remote_raphael.id],
"service_types" => []
{"service_types" => []}
)
retraction.defer_dispatch(local_luke)
@ -87,7 +87,7 @@ describe Retraction do
expect(Workers::DeferredRetraction).to receive(:perform_async).with(
alice.id, "Retraction", federation_retraction.to_h.deep_stringify_keys, [],
"service_types" => ["Services::Twitter"], "tweet_id" => "123"
{"service_types" => ["Services::Twitter"], "tweet_id" => "123"}
)
retraction.defer_dispatch(alice)
@ -98,7 +98,7 @@ describe Retraction do
federation_retraction = Diaspora::Federation::Entities.retraction(retraction)
expect(Workers::DeferredRetraction).to receive(:perform_async).with(
alice.id, "Retraction", federation_retraction.to_h.deep_stringify_keys, [], "service_types" => []
alice.id, "Retraction", federation_retraction.to_h.deep_stringify_keys, [], {"service_types" => []}
)
retraction.defer_dispatch(alice)

View file

@ -181,7 +181,7 @@ describe User::Connecting, type: :model do
it "delivers profile for remote persons" do
allow(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch)
expect(Diaspora::Federation::Dispatcher)
.to receive(:defer_dispatch).with(alice, alice.profile, subscriber_ids: [remote_raphael.id])
.to receive(:defer_dispatch).with(alice, alice.profile, {subscriber_ids: [remote_raphael.id]})
alice.share_with(remote_raphael, alice.aspects.first)
end

View file

@ -6,8 +6,7 @@ describe Workers::Mail::InviteEmail do
let(:email_inviter) { double('EmailInviter') }
it 'creates a new email inviter' do
expect(EmailInviter).to receive(:new).with(emails, alice, message: message)
.and_return(email_inviter)
expect(EmailInviter).to receive(:new).with(emails, alice, {message: message}).and_return(email_inviter)
expect(email_inviter).to receive(:send!)
Workers::Mail::InviteEmail.new.perform(emails, alice.id, message: message)
end