Skip to content

Commit 2ccb037

Browse files
committed
Coerced test
1 parent 711339e commit 2ccb037

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ def test_validate_uniqueness_by_default_database_collation_coerced
4545
assert_equal 1, Topic.where(author_email_address: "david@loudthinking.com").count
4646
assert_equal 1, Topic.where(author_email_address: "David@loudthinking.com").count
4747
end
48+
49+
# Need to explicitly set the WHERE clause to truthy.
50+
coerce_tests! :test_partial_index
51+
def test_partial_index_coerced
52+
Topic.validates_uniqueness_of(:title)
53+
@connection.add_index(:topics, :title, unique: true, where: "approved=1", name: :topics_index)
54+
55+
t = Topic.create!(title: "abc")
56+
t.author_name = "John"
57+
assert_queries(1) do
58+
t.valid?
59+
end
60+
end
4861
end
4962

5063
require "models/event"

0 commit comments

Comments
 (0)