aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation/predicate_builder_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/relation/predicate_builder_test.rb')
-rw-r--r--activerecord/test/cases/relation/predicate_builder_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/predicate_builder_test.rb b/activerecord/test/cases/relation/predicate_builder_test.rb
new file mode 100644
index 0000000000..1c87f5c12e
--- /dev/null
+++ b/activerecord/test/cases/relation/predicate_builder_test.rb
@@ -0,0 +1,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'}, Topic.where(title: /rails/).to_sql
+ end
+ end
+end