aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/relation/predicate_builder_test.rb
blob: 48758dc1480f7aba7465537e0500f76e002a1a7f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                      
                      



                                                     
                                                                              
                                                                            

          
                                                                                                 

                                    


       
require "cases/helper"
require "models/topic"

module ActiveRecord
  class PredicateBuilderTest < ActiveRecord::TestCase
    def test_registering_new_handlers
      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
    end
  end
end