Skip to content

Commit

Permalink
Fix some keyword args for ruby 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTux88 committed Jul 20, 2022
1 parent 93c69c4 commit 022f367
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions app/helpers/notifications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def object_link(note, actors_html)
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)
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/report_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def new_report(type, id, reason, role)
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} }
Expand Down
8 changes: 6 additions & 2 deletions app/presenters/base_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ def initialize(presentable, curr_user=nil)
@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
Expand Down
2 changes: 1 addition & 1 deletion features/support/application_cuke_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def flash_message_containing?(text)
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)
Expand Down
2 changes: 1 addition & 1 deletion features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def navigate_to(page_name)
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
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/diaspora/federated/retraction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

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)
Expand All @@ -87,7 +87,7 @@

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)
Expand All @@ -98,7 +98,7 @@
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)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/user/connecting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
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
Expand Down
3 changes: 1 addition & 2 deletions spec/workers/mail/invite_email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
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
Expand Down

0 comments on commit 022f367

Please sign in to comment.