Make ActiveSupport::Duration#method_missing delegate blocks to value [#5498 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Krekoten' Marjan 2010-08-30 22:50:44 +03:00 committed by José Valim
parent dba4efbd0e
commit 57693d1362
2 changed files with 9 additions and 1 deletions

@ -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

@ -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')