aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDiego Carrion <dc.rec1@gmail.com>2011-03-04 16:09:01 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-03-04 18:07:48 -0200
commit1f47061b483ed40b6acbecdab486f4733d708528 (patch)
tree7652ba0ec6cb43d745fa8c9224286b11e26fea7d /activesupport/test
parent7872cc992bac76e976334d0c20649d69aad5652e (diff)
downloadrails-1f47061b483ed40b6acbecdab486f4733d708528.tar.gz
rails-1f47061b483ed40b6acbecdab486f4733d708528.tar.bz2
rails-1f47061b483ed40b6acbecdab486f4733d708528.zip
reverted tests deleted by 080345baca1076a9788d, refactored implementations should not invalidate the validations
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 891a6badac..53d497013a 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -533,9 +533,19 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
Time::DATE_FORMATS.delete(:custom)
end
- def test_conversion_methods_are_publicized
- assert Time.public_instance_methods.include?(:to_date) || Time.public_instance_methods.include?('to_date')
- assert Time.public_instance_methods.include?(:to_datetime) || Time.public_instance_methods.include?('to_datetime')
+ def test_to_date
+ assert_equal Date.new(2005, 2, 21), Time.local(2005, 2, 21, 17, 44, 30).to_date
+ end
+
+ def test_to_datetime
+ assert_equal Time.utc(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, 0, 0)
+ with_env_tz 'US/Eastern' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ with_env_tz 'NZ' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ assert_equal ::Date::ITALY, Time.utc(2005, 2, 21, 17, 44, 30).to_datetime.start # use Ruby's default start value
end
def test_to_time