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
15 changes: 8 additions & 7 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,15 +790,16 @@ def test_update_all_doesnt_ignore_order_coerced
require 'models/topic'
module ActiveRecord
class PredicateBuilderTest < ActiveRecord::TestCase
# Use Square brackets around column name
# Same as original test except string has `N` prefix to indicate unicode string.
coerce_tests! :test_registering_new_handlers
def test_registering_new_handlers_coerced
Topic.predicate_builder.register_handler(Regexp, proc do |column, value|
Arel::Nodes::InfixOperation.new('~', column, Arel.sql(value.source))
end)
assert_match %r{\[topics\].\[title\] ~ rails}i, Topic.where(title: /rails/).to_sql
ensure
Topic.reset_column_information
assert_match %r{#{Regexp.escape(topic_title)} ~ N'rails'}i, Topic.where(title: /rails/).to_sql
end

# Same as original test except string has `N` prefix to indicate unicode string.
coerce_tests! :test_registering_new_handlers_for_association
def test_registering_new_handlers_for_association_coerced
assert_match %r{#{Regexp.escape(topic_title)} ~ N'rails'}i, Reply.joins(:topic).where(topics: { title: /rails/ }).to_sql
end
end
end
Expand Down