1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

TimeWithZone #wday, #yday and #to_date avoid trip through #method_missing

This commit is contained in:
gbuesing 2008-09-14 23:07:48 -05:00
parent cce7ae5466
commit 157141b294
3 changed files with 6 additions and 2 deletions

View file

@ -1,5 +1,7 @@
*Edge*
* TimeWithZone #wday, #yday and #to_date avoid trip through #method_missing [Geoff Buesing]
* Added Time, Date, DateTime and TimeWithZone #past?, #future? and #today? #720 [Clemens Kofler, Geoff Buesing]
* Fixed Sri Jayawardenepura time zone to map to Asia/Colombo [Jamis Buck]

View file

@ -231,7 +231,7 @@ module ActiveSupport
end
end
%w(year mon month day mday hour min sec).each do |method_name|
%w(year mon month day mday wday yday hour min sec to_date).each do |method_name|
class_eval <<-EOV
def #{method_name}
time.#{method_name}

View file

@ -397,7 +397,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
def test_date_part_value_methods
silence_warnings do # silence warnings raised by tzinfo gem
twz = ActiveSupport::TimeWithZone.new(Time.utc(1999,12,31,19,18,17,500), @time_zone)
twz.stubs(:method_missing).returns(nil) #ensure these methods are defined directly on class
twz.expects(:method_missing).never
assert_equal 1999, twz.year
assert_equal 12, twz.month
assert_equal 31, twz.day
@ -405,6 +405,8 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert_equal 18, twz.min
assert_equal 17, twz.sec
assert_equal 500, twz.usec
assert_equal 5, twz.wday
assert_equal 365, twz.yday
end
end
end