Skip to content

Commit e0ce6bb

Browse files
committed
Fix kwargs delegation in PerThreadRegistry#method_missing
Without this fix, the delegation will raise the ArgumentError: ``` % bin/test -w test/per_thread_registry_test.rb Running 1 tests in a single process (parallelization threshold is 50) Run options: --seed 23992 # Running: E Error: PerThreadRegistryTest#test_method_missing_with_kwargs: ArgumentError: wrong number of arguments (given 1, expected 0; required keyword: x) /Users/kamipo/src/github.com/rails/rails/activesupport/test/per_thread_registry_test.rb:9:in `foo' /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/per_thread_registry.rb:55:in `foo' /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/per_thread_registry.rb:57:in `method_missing' /Users/kamipo/src/github.com/rails/rails/activesupport/test/per_thread_registry_test.rb:13:in `test_method_missing_with_kwargs' ```
1 parent f9468ad commit e0ce6bb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

activesupport/lib/active_support/per_thread_registry.rb

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

5757
send(name, *args, &block)
5858
end
59+
ruby2_keywords(:method_missing)
5960
end
6061
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "abstract_unit"
4+
5+
class PerThreadRegistryTest < ActiveSupport::TestCase
6+
class TestRegistry
7+
extend ActiveSupport::PerThreadRegistry
8+
9+
def foo(x:); x; end
10+
end
11+
12+
def test_method_missing_with_kwargs
13+
assert_equal 1, TestRegistry.foo(x: 1)
14+
end
15+
end

0 commit comments

Comments
 (0)