Skip to content

Commit

Permalink
before_type_cast on Datetime tests for Mysql2Adapter
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
amatsuda authored and spastorino committed Feb 1, 2011
1 parent c8b7606 commit 4e6a102
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions activerecord/test/cases/attribute_methods_test.rb
Expand Up @@ -116,20 +116,23 @@ def test_read_attributes_before_type_cast_on_boolean
end
end

unless current_adapter?(:Mysql2Adapter)
def test_read_attributes_before_type_cast_on_datetime
developer = Developer.find(:first)
def test_read_attributes_before_type_cast_on_datetime
developer = Developer.find(:first)
if current_adapter?(:Mysql2Adapter)
# Mysql2 keeps the value in Time instance
assert_equal developer.created_at.to_s(:db), developer.attributes_before_type_cast["created_at"].to_s(:db)
else
assert_equal developer.created_at.to_s(:db), developer.attributes_before_type_cast["created_at"].to_s
end

developer.created_at = "345643456"
developer.created_at = "345643456"

assert_equal developer.created_at_before_type_cast, "345643456"
assert_equal developer.created_at, nil
assert_equal developer.created_at_before_type_cast, "345643456"
assert_equal developer.created_at, nil

developer.created_at = "2010-03-21 21:23:32"
assert_equal developer.created_at_before_type_cast.to_s, "2010-03-21 21:23:32"
assert_equal developer.created_at, Time.parse("2010-03-21 21:23:32")
end
developer.created_at = "2010-03-21 21:23:32"
assert_equal developer.created_at_before_type_cast.to_s, "2010-03-21 21:23:32"
assert_equal developer.created_at, Time.parse("2010-03-21 21:23:32")
end

def test_hash_content
Expand Down

0 comments on commit 4e6a102

Please sign in to comment.