diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-10-16 11:40:41 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-10-16 11:56:50 +0200 |
commit | f18a4d07eff6f20871d0e7c48d28d5a9f744a487 (patch) | |
tree | 6e49cad1d694771d0887c49c595a6c1965c05be9 /activerecord | |
parent | 01a4ae9d76d995d448a6edc25b839e60f8d8628a (diff) | |
download | rails-f18a4d07eff6f20871d0e7c48d28d5a9f744a487.tar.gz rails-f18a4d07eff6f20871d0e7c48d28d5a9f744a487.tar.bz2 rails-f18a4d07eff6f20871d0e7c48d28d5a9f744a487.zip |
pg, test assigning non-array values to an array column. Closes #14716.
The behavior has changed since 4.1 and non-array values are no
longer type casted to a blank array. This way the user can define
custom validations on that property.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/array_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/array_test.rb b/activerecord/test/cases/adapters/postgresql/array_test.rb index ff553c3f1a..fa7bebf08b 100644 --- a/activerecord/test/cases/adapters/postgresql/array_test.rb +++ b/activerecord/test/cases/adapters/postgresql/array_test.rb @@ -254,6 +254,15 @@ class PostgresqlArrayTest < ActiveRecord::TestCase end end + def test_assigning_non_array_value + record = PgArray.new(tags: "not-an-array") + assert_equal "not-an-array", record.tags + e = assert_raises(ActiveRecord::StatementInvalid) do + record.save! + end + assert_instance_of PG::InvalidTextRepresentation, e.original_exception + end + private def assert_cycle field, array # test creation |