diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-29 10:46:35 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 10:46:35 +0900 |
commit | 3cf0973bc7aab24e2245dce66282e8be94c9d362 (patch) | |
tree | ff4828d0cb2e0617e2b3ae000e8ff6dc5d4196d4 /activerecord/test/cases | |
parent | e57e0a92e798d7d9cf2a37447e553ee67942526a (diff) | |
parent | bbcb1c9e6bec7a517bb4d65e026d6e85d4a04ffb (diff) | |
download | rails-3cf0973bc7aab24e2245dce66282e8be94c9d362.tar.gz rails-3cf0973bc7aab24e2245dce66282e8be94c9d362.tar.bz2 rails-3cf0973bc7aab24e2245dce66282e8be94c9d362.zip |
Merge pull request #31615 from cben/type_for_attribute-symbol
Allow type_for_attribute(:symbol)
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/reflection_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index ee343ba380..ed19192ad9 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -66,6 +66,9 @@ class ReflectionTest < ActiveRecord::TestCase def test_column_string_type_and_limit assert_equal :string, @first.column_for_attribute("title").type + assert_equal :string, @first.column_for_attribute(:title).type + assert_equal :string, @first.type_for_attribute("title").type + assert_equal :string, @first.type_for_attribute(:title).type assert_equal 250, @first.column_for_attribute("title").limit end @@ -81,6 +84,9 @@ class ReflectionTest < ActiveRecord::TestCase def test_integer_columns assert_equal :integer, @first.column_for_attribute("id").type + assert_equal :integer, @first.column_for_attribute(:id).type + assert_equal :integer, @first.type_for_attribute("id").type + assert_equal :integer, @first.type_for_attribute(:id).type end def test_non_existent_columns_return_null_object @@ -89,6 +95,9 @@ class ReflectionTest < ActiveRecord::TestCase assert_equal "attribute_that_doesnt_exist", column.name assert_nil column.sql_type assert_nil column.type + + column = @first.column_for_attribute(:attribute_that_doesnt_exist) + assert_instance_of ActiveRecord::ConnectionAdapters::NullColumn, column end def test_non_existent_types_are_identity_types @@ -98,6 +107,11 @@ class ReflectionTest < ActiveRecord::TestCase assert_equal object, type.deserialize(object) assert_equal object, type.cast(object) assert_equal object, type.serialize(object) + + type = @first.type_for_attribute(:attribute_that_doesnt_exist) + assert_equal object, type.deserialize(object) + assert_equal object, type.cast(object) + assert_equal object, type.serialize(object) end def test_reflection_klass_for_nested_class_name |