Skip to content
Browse files

TimeWithZone #wday, #yday and #to_date avoid trip through #method_mis…

…sing
  • Loading branch information...
1 parent cce7ae5 commit 157141b2949b845e372ee703bfd6fba3ffb00415 @gbuesing gbuesing committed Sep 14, 2008
View
2 activesupport/CHANGELOG
@@ -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
2 activesupport/lib/active_support/time_with_zone.rb
@@ -231,7 +231,7 @@ def advance(options)
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
4 activesupport/test/core_ext/time_with_zone_test.rb
@@ -397,14 +397,16 @@ def test_method_missing_with_non_time_return_value
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
assert_equal 14, twz.hour
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

0 comments on commit 157141b

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