diff options
author | Kir Shatrov <shatrov@me.com> | 2017-06-21 13:58:07 -0400 |
---|---|---|
committer | Kir Shatrov <shatrov@me.com> | 2017-08-04 16:47:55 +0300 |
commit | a0751d27c52185b86370baf6a565e757092646de (patch) | |
tree | fa6a305d42e5b736fd3534e59ee1c7c25cbcfe5c /activerecord/test/cases/adapters | |
parent | 904f1a8747958129124d86b44e36c5f0263e0125 (diff) | |
download | rails-a0751d27c52185b86370baf6a565e757092646de.tar.gz rails-a0751d27c52185b86370baf6a565e757092646de.tar.bz2 rails-a0751d27c52185b86370baf6a565e757092646de.zip |
Do not let use `serialize` on native JSON/array column
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/array_test.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/array_test.rb b/activerecord/test/cases/adapters/postgresql/array_test.rb index 8507dbb463..08b17f37e2 100644 --- a/activerecord/test/cases/adapters/postgresql/array_test.rb +++ b/activerecord/test/cases/adapters/postgresql/array_test.rb @@ -47,6 +47,15 @@ class PostgresqlArrayTest < ActiveRecord::PostgreSQLTestCase assert ratings_column.array? end + def test_not_compatible_with_serialize + new_klass = Class.new(PgArray) do + serialize :tags, Array + end + assert_raises(ActiveRecord::AttributeMethods::Serialization::ColumnNotSerializableError) do + new_klass.new + end + end + def test_default @connection.add_column "pg_arrays", "score", :integer, array: true, default: [4, 4, 2] PgArray.reset_column_information diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index aa5e03df41..79dcfe110c 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -33,6 +33,15 @@ module PostgresqlJSONSharedTestCases x.reload assert_equal ["foo" => "bar"], x.objects end + + def test_not_compatible_with_serialize_macro + new_klass = Class.new(klass) do + serialize :payload, JSON + end + assert_raises(ActiveRecord::AttributeMethods::Serialization::ColumnNotSerializableError) do + new_klass.new + end + end end class PostgresqlJSONTest < ActiveRecord::PostgreSQLTestCase |