Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ def test_validate_uniqueness_with_limit_and_utf8_coerced
end
end
end

# Same as original coerced test except that it handles default SQL Server case-insensitive collation.
coerce_tests! :test_validate_uniqueness_by_default_database_collation
def test_validate_uniqueness_by_default_database_collation_coerced
Topic.validates_uniqueness_of(:author_email_address)

topic1 = Topic.new(author_email_address: "[email protected]")
topic2 = Topic.new(author_email_address: "[email protected]")

assert_equal 1, Topic.where(author_email_address: "[email protected]").count

assert_not topic1.valid?
assert_not topic1.save

# Case insensitive collation (SQL_Latin1_General_CP1_CI_AS) by default.
# Should not allow "David" if "david" exists.
assert_not topic2.valid?
assert_not topic2.save

assert_equal 1, Topic.where(author_email_address: "[email protected]").count
assert_equal 1, Topic.where(author_email_address: "[email protected]").count
end
end

require "models/event"
Expand Down