Permalink
Browse files

Fix NamedScope regex so methods containing "an" get delegated to prox…

…y_found. [#901 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 6577942 commit db116a2ed688d36570f412a42e9fc33dcbca56c7 @DefV DefV committed with lifo Aug 25, 2008
Showing with 5 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/named_scope.rb
  2. +4 −0 activerecord/test/cases/named_scope_test.rb
@@ -103,7 +103,7 @@ class Scope
attr_reader :proxy_scope, :proxy_options
[].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\?)/
@mislav

mislav Aug 29, 2008

Member

Why aren’t more than half of these regexes anchored to the beginning and end of string, like the ones in the beginning are?

delegate m, :to => :proxy_found
end
end
@@ -249,6 +249,10 @@ def test_find_all_should_behave_like_select
assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved)
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
assert_equal Developer.find_all_by_name('Jamis'), Developer.find_all_by_id(Developer.jamises)
end

2 comments on commit db116a2

Contributor

ryanb replied Aug 29, 2008

That’s what I’m wondering too mislav.

Member

NZKoz replied Aug 29, 2008

Let’s see: http://github.com/rails/rails/commit/99492ba

Please sign in to comment.