Skip to content
Browse files

Make ActiveSupport::Duration#method_missing delegate blocks to value [#…

…5498 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 9c5248f commit 2adad2a0cc6e6179cb03b6e2c61d7e8efd46389e @krekoten krekoten committed with josevalim Aug 30, 2010
Showing with 9 additions and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/duration.rb
  2. +8 −0 activesupport/test/core_ext/duration_test.rb
View
2 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
View
8 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')

0 comments on commit 2adad2a

Please sign in to comment.
Something went wrong with that request. Please try again.