Skip to content

Commit

Permalink
fix: backport the fix for the return value of #deep_transform_keys (#750
Browse files Browse the repository at this point in the history
)

Backport fix the return value of #deep_transform_keys
  • Loading branch information
fixtheclouds committed Jan 30, 2023
1 parent 8c6da81 commit b7b08d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def slice!(*keys)
def _deep_transform_keys_in_object(object, &block)
case object
when Hash
object.each_with_object({}) do |(key, value), result|
object.each_with_object(self.class.new) do |(key, value), result|
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
end
when Array
Expand Down
14 changes: 14 additions & 0 deletions spec/sidekiq_unique_jobs/core_ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
end
end

describe "ExtendedHash" do
before do
stub_const("ExtendedHash", Hash)
end

let(:hash) { ExtendedHash[:test, :me, :not, :me] }

describe "#deep_transform_keys" do
subject(:deep_transform_keys) { hash.deep_transform_keys(&:to_s) }

it { is_expected.to be_a(ExtendedHash) }
end
end

describe Array do
let(:array) { [1, 2, nil, last_argument] }
let(:last_argument) { Object.new }
Expand Down

0 comments on commit b7b08d8

Please sign in to comment.