Skip to content

Commit c1e6127

Browse files
authored
Merge pull request #45951 from vojtad/fix-active-support-current-attributes-for-ruby-3
Fix ActiveSupport::CurrentAttributes for Ruby 3
2 parents e74d6ee + ad24aa5 commit c1e6127

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

activesupport/lib/active_support/current_attributes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def method_missing(name, *args, &block)
164164

165165
send(name, *args, &block)
166166
end
167+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
167168
end
168169

169170
attr_accessor :attributes

activesupport/test/current_attributes_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ def person=(person)
3131
Session.current = person&.id
3232
end
3333

34+
def set_world_and_account(world:, account:)
35+
self.world = world
36+
self.account = account
37+
end
38+
39+
def get_world_and_account(hash)
40+
hash[:world] = world
41+
hash[:account] = account
42+
hash
43+
end
44+
3445
def request
3546
"#{super} something"
3647
end
@@ -126,6 +137,18 @@ def after_teardown
126137
assert_equal "account/1", Current.account
127138
end
128139

140+
test "using keyword arguments" do
141+
Current.set_world_and_account(world: "world/1", account: "account/1")
142+
143+
assert_equal "world/1", Current.world
144+
assert_equal "account/1", Current.account
145+
146+
hash = {}
147+
assert_same hash, Current.get_world_and_account(hash)
148+
assert_equal "world/1", hash[:world]
149+
assert_equal "account/1", hash[:account]
150+
end
151+
129152
setup { @testing_teardown = false }
130153
teardown { assert_equal 42, Session.current if @testing_teardown }
131154

0 commit comments

Comments
 (0)