aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 14:12:16 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 14:12:16 -0700
commita3936bbe21f4bff8247f890cacfd0fc882921003 (patch)
tree615ff2d3ed709121f8aea1a2cd6eb56870af0ce9 /activerecord/test
parentaf55197d86676c371a0a50e62c162df4d6006849 (diff)
downloadrails-a3936bbe21f4bff8247f890cacfd0fc882921003.tar.gz
rails-a3936bbe21f4bff8247f890cacfd0fc882921003.tar.bz2
rails-a3936bbe21f4bff8247f890cacfd0fc882921003.zip
Change `PredicateBuilder` handler methods to instance methods
This will allow us to pass the predicate builder into the constructor of these handlers. The procs had to be changed to objects, because the `PredicateBuilder` needs to be marshalable. If we ever decide to make `register_handler` part of the public API, we should come up with a better solution which allows procs. /cc @mrgilman [Sean Griffin & Melanie Gilman]
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/relation/predicate_builder_test.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/test/cases/relation/predicate_builder_test.rb b/activerecord/test/cases/relation/predicate_builder_test.rb
index 4057835688..0cc081fced 100644
--- a/activerecord/test/cases/relation/predicate_builder_test.rb
+++ b/activerecord/test/cases/relation/predicate_builder_test.rb
@@ -4,11 +4,13 @@ require 'models/topic'
module ActiveRecord
class PredicateBuilderTest < ActiveRecord::TestCase
def test_registering_new_handlers
- PredicateBuilder.register_handler(Regexp, proc do |column, value|
+ 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