aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 13:03:31 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 13:04:29 -0700
commita983e1e89c6f55cd08feb394db33ca0620fadfd1 (patch)
treea24fed0cf84a37df77b82c3e6e36dce951c29f5d /activerecord/test/cases/adapters/postgresql
parentaff03e71b4a9d5b0d9190c52ecded79f44e937ce (diff)
downloadrails-a983e1e89c6f55cd08feb394db33ca0620fadfd1.tar.gz
rails-a983e1e89c6f55cd08feb394db33ca0620fadfd1.tar.bz2
rails-a983e1e89c6f55cd08feb394db33ca0620fadfd1.zip
Correctly ignore `case_sensitive` for UUID uniqueness validation
I think we should deprecate this behavior and just error if you tell us to do a case insensitive comparison for types which are not case sensitive. Partially reverts 35592307 Fixes #18195
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r--activerecord/test/cases/adapters/postgresql/uuid_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
index 3c967d73da..d5d2dd16e2 100644
--- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
@@ -116,6 +116,23 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase
output = dump_table_schema "uuid_data_type"
assert_match %r{t.uuid "guid"}, output
end
+
+ def test_uniqueness_validation_ignores_uuid
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = "uuid_data_type"
+ validates :guid, uniqueness: { case_sensitive: false }
+
+ def self.name
+ "UUIDType"
+ end
+ end
+
+ record = klass.create!(guid: "a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11")
+ duplicate = klass.new(guid: record.guid)
+
+ assert record.guid.present? # Ensure we actually are testing a UUID
+ assert_not duplicate.valid?
+ end
end
class PostgresqlLargeKeysTest < ActiveRecord::TestCase