aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/relation/predicate_builder_test.rb
blob: 0cc081fcedef986240af498b527c54101cdc1456 (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