Skip to content
This repository
Browse code

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

…y_found

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

Conflicts:

	activerecord/lib/active_record/named_scope.rb
  • Loading branch information...
commit c37900138c565f7dacbbfbe20f9c397da7ec49c4 1 parent e27e1f0
Michael Koziarski NZKoz authored
2  activerecord/lib/active_record/named_scope.rb
@@ -103,7 +103,7 @@ class Scope
103 103 attr_reader :proxy_scope, :proxy_options
104 104
105 105 [].methods.each do |m|
106   - unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty?|respond_to?)/
  106 + unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty\?|respond_to\?)/
107 107 delegate m, :to => :proxy_found
108 108 end
109 109 end
4 activerecord/test/cases/named_scope_test.rb
@@ -196,6 +196,10 @@ def test_find_all_should_behave_like_select
196 196 assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved)
197 197 end
198 198
  199 + def test_rand_should_select_a_random_object_from_proxy
  200 + assert Topic.approved.rand.is_a? Topic
  201 + end
  202 +
199 203 def test_should_use_where_in_query_for_named_scope
200 204 assert_equal Developer.find_all_by_name('Jamis'), Developer.find_all_by_id(Developer.jamises)
201 205 end

0 comments on commit c379001

Please sign in to comment.
Something went wrong with that request. Please try again.