aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/array_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-10-16 11:40:41 +0200
committerYves Senn <yves.senn@gmail.com>2014-10-16 11:56:50 +0200
commitf18a4d07eff6f20871d0e7c48d28d5a9f744a487 (patch)
tree6e49cad1d694771d0887c49c595a6c1965c05be9 /activerecord/test/cases/adapters/postgresql/array_test.rb
parent01a4ae9d76d995d448a6edc25b839e60f8d8628a (diff)
downloadrails-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/test/cases/adapters/postgresql/array_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/array_test.rb9
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