-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
711339e
commit 2ccb037
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,19 @@ def test_validate_uniqueness_by_default_database_collation_coerced | |
assert_equal 1, Topic.where(author_email_address: "[email protected]").count | ||
assert_equal 1, Topic.where(author_email_address: "[email protected]").count | ||
end | ||
|
||
# Need to explicitly set the WHERE clause to truthy. | ||
coerce_tests! :test_partial_index | ||
def test_partial_index_coerced | ||
Topic.validates_uniqueness_of(:title) | ||
@connection.add_index(:topics, :title, unique: true, where: "approved=1", name: :topics_index) | ||
|
||
t = Topic.create!(title: "abc") | ||
t.author_name = "John" | ||
assert_queries(1) do | ||
t.valid? | ||
end | ||
end | ||
end | ||
|
||
require "models/event" | ||
|