Skip to content

Commit

Permalink
Coerced test
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Sep 26, 2023
1 parent 711339e commit 2ccb037
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2ccb037

Please sign in to comment.