1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix NamedScope regex so methods containing "an" get delegated to proxy_found. [#901 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Jan De Poorter 2008-08-25 12:37:34 +02:00 committed by Pratik Naik
parent 6577942b61
commit db116a2ed6
2 changed files with 5 additions and 1 deletions

View file

@ -103,7 +103,7 @@ module ActiveRecord
attr_reader :proxy_scope, :proxy_options attr_reader :proxy_scope, :proxy_options
[].methods.each do |m| [].methods.each do |m|
unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty?|any?|respond_to?)/ unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty\?|any\?|respond_to\?)/
delegate m, :to => :proxy_found delegate m, :to => :proxy_found
end end
end end

View file

@ -249,6 +249,10 @@ class NamedScopeTest < ActiveRecord::TestCase
assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved) assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved)
end end
def test_rand_should_select_a_random_object_from_proxy
assert Topic.approved.rand.is_a? Topic
end
def test_should_use_where_in_query_for_named_scope def test_should_use_where_in_query_for_named_scope
assert_equal Developer.find_all_by_name('Jamis'), Developer.find_all_by_id(Developer.jamises) assert_equal Developer.find_all_by_name('Jamis'), Developer.find_all_by_id(Developer.jamises)
end end