aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation/predicate_builder_test.rb
blob: 14a8d97d368a5b2b5a1e07e12bd510d0623295e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require "cases/helper"
require 'models/topic'

module ActiveRecord
  class PredicateBuilderTest < ActiveRecord::TestCase
    def test_registering_new_handlers
      PredicateBuilder.register_handler(Regexp, proc do |column, value|
        Arel::Nodes::InfixOperation.new('~', column, value.source)
      end)

      assert_match %r{["`]topics["`].["`]title["`] ~ 'rails'}i, Topic.where(title: /rails/).to_sql
    end
  end
end