Skip to content

Commit

Permalink
Fix NamedScope regex so methods containing "an" get delegated to prox…
Browse files Browse the repository at this point in the history
…y_found

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#901 state:committed]

Conflicts:

	activerecord/lib/active_record/named_scope.rb
  • Loading branch information
NZKoz committed Aug 29, 2008
1 parent e27e1f0 commit c379001
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/named_scope.rb
Expand Up @@ -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?|respond_to?)/
unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty\?|respond_to\?)/
delegate m, :to => :proxy_found
end
end
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/named_scope_test.rb
Expand Up @@ -196,6 +196,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
Expand Down

0 comments on commit c379001

Please sign in to comment.