diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index a535e2b668..de3ded1e1f 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -99,7 +99,7 @@ def sum(sign, time = ::Time.current) #:nodoc: private def method_missing(method, *args, &block) #:nodoc: - value.send(method, *args) + value.send(method, *args, &block) end end end diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 8469f78566..b6456f0a30 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -129,6 +129,14 @@ def test_adding_day_across_dst_boundary assert_equal Time.local(2009,3,29,0,0,0) + 1.day, Time.local(2009,3,30,0,0,0) end end + + def test_delegation_with_block_works + counter = 0 + assert_nothing_raised do + 1.minute.times {counter += 1} + end + assert_equal counter, 60 + end protected def with_env_tz(new_tz = 'US/Eastern')