aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/connection_adapters/type/type_map_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/connection_adapters/type/type_map_test.rb')
-rw-r--r--activerecord/test/cases/connection_adapters/type/type_map_test.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/test/cases/connection_adapters/type/type_map_test.rb b/activerecord/test/cases/connection_adapters/type/type_map_test.rb
index 565f44eef8..4b4d9f6b0f 100644
--- a/activerecord/test/cases/connection_adapters/type/type_map_test.rb
+++ b/activerecord/test/cases/connection_adapters/type/type_map_test.rb
@@ -21,7 +21,7 @@ module ActiveRecord
def test_overriding_registered_types
time = Time.new
- timestamp = Timestamp.new
+ timestamp = DateTime.new
mapping = TypeMap.new
mapping.register_type(/time/i, time)
@@ -51,7 +51,7 @@ module ActiveRecord
def test_changing_type_changes_aliases
time = Time.new
- timestamp = Timestamp.new
+ timestamp = DateTime.new
mapping = TypeMap.new
mapping.register_type(/timestamp/i, time)
@@ -95,6 +95,19 @@ module ActiveRecord
mapping.register_type(/only key/i)
end
end
+
+ def test_lookup_non_strings
+ mapping = HashLookupTypeMap.new
+
+ mapping.register_type(1, 'string')
+ mapping.register_type(2, 'int')
+ mapping.alias_type(3, 1)
+
+ assert_equal mapping.lookup(1), 'string'
+ assert_equal mapping.lookup(2), 'int'
+ assert_equal mapping.lookup(3), 'string'
+ assert_kind_of Type::Value, mapping.lookup(4)
+ end
end
end
end