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

[v3.3] Fix publishing events responding to #to_hash on Ruby 2.7 #4895

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Feb 1, 2023

Backport

This will backport the following commits from master to v3.3:

Questions ?

Please refer to the Backport tool documentation

When a method accepts both splatted positional & keyword parameters and
a single argument responding to `#to_hash` is given, the argument is
coerced to hash and assigned to the keyword arguments.

E.g.:

class Hashable
  def to_hash
    { im: :a_hash }
  end
end

def method_with_splat_on_the_positional_argument(*args, **kwargs) # method_with_splat_on_the_positional_argument(Hashable.new)
  puts args.inspect # =>  []
  puts kwargs.inspect # => {:im=>:a_hash}
end

However,

def method_without_splat_on_the_positional_argument(args, **kwargs) # method_without_splat_on_the_positional_argument(Hashable.new)
  puts args.inspect # => #<Hashable:0x000055cfe8b072b0>
  puts kwargs.inspect # => {}
end

We fix the problem on the Spree::Bus override by being explicit about
the expected parameters.

References solidusio/solidus_stripe#157 (comment)

(cherry picked from commit d69f8d7)
@github-actions github-actions bot requested a review from a team as a code owner February 1, 2023 11:44
@waiting-for-dev waiting-for-dev changed the title [v3.3] Merge pull request #4875 from nebulab/waiting-for-dev/event_to_hash_ruby_v2.7 [v3.3] Fix publishing events responding to #to_hash on Ruby 2.7 Feb 1, 2023
@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Merging #4895 (bd2a80f) into v3.3 (2c05ab4) will not change coverage.
The diff coverage is 66.66%.

@@           Coverage Diff           @@
##             v3.3    #4895   +/-   ##
=======================================
  Coverage   86.25%   86.25%           
=======================================
  Files         577      577           
  Lines       14678    14678           
=======================================
  Hits        12660    12660           
  Misses       2018     2018           
Impacted Files Coverage Δ
core/lib/spree/bus.rb 85.71% <66.66%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@waiting-for-dev waiting-for-dev merged commit 6f916da into v3.3 Feb 1, 2023
@waiting-for-dev waiting-for-dev deleted the backport/v3.3/pr-4875 branch February 1, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant