File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,28 @@ def test_validate_uniqueness_with_limit_and_utf8_coerced
2323 end
2424 end
2525 end
26+
27+ # Same as original coerced test except that it handles default SQL Server case-insensitive collation.
28+ coerce_tests! :test_validate_uniqueness_by_default_database_collation
29+ def test_validate_uniqueness_by_default_database_collation_coerced
30+ Topic . validates_uniqueness_of ( :author_email_address )
31+
32+ topic1 = Topic . new ( author_email_address : "david@loudthinking.com" )
33+ topic2 = Topic . new ( author_email_address : "David@loudthinking.com" )
34+
35+ assert_equal 1 , Topic . where ( author_email_address : "david@loudthinking.com" ) . count
36+
37+ assert_not topic1 . valid?
38+ assert_not topic1 . save
39+
40+ # Case insensitive collation (SQL_Latin1_General_CP1_CI_AS) by default.
41+ # Should not allow "David" if "david" exists.
42+ assert_not topic2 . valid?
43+ assert_not topic2 . save
44+
45+ assert_equal 1 , Topic . where ( author_email_address : "david@loudthinking.com" ) . count
46+ assert_equal 1 , Topic . where ( author_email_address : "David@loudthinking.com" ) . count
47+ end
2648end
2749
2850require "models/event"
You can’t perform that action at this time.
0 commit comments