Skip to content

Commit

Permalink
reverted tests deleted by 080345b, refactored implementations should …
Browse files Browse the repository at this point in the history
…not invalidate the validations

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
dcrec1 authored and spastorino committed Mar 4, 2011
1 parent 7872cc9 commit 1f47061
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions activesupport/test/core_ext/time_ext_test.rb
Expand Up @@ -533,9 +533,19 @@ def test_custom_date_format
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
Expand Down

0 comments on commit 1f47061

Please sign in to comment.