aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2012-06-07 12:55:39 +0900
committerkennyj <kennyj@gmail.com>2012-06-10 23:55:42 +0900
commitcd1be1acc68221fbdfab0d13211d40bdeae630dc (patch)
treea87fc3fafbe6f07a9221ff69f30812eaf58c5d49 /activerecord/test
parent42259f69ae3fa2daacfb751dbc663adb14159e37 (diff)
downloadrails-cd1be1acc68221fbdfab0d13211d40bdeae630dc.tar.gz
rails-cd1be1acc68221fbdfab0d13211d40bdeae630dc.tar.bz2
rails-cd1be1acc68221fbdfab0d13211d40bdeae630dc.zip
Fix #6635. We should call Scoping methods, before calling Array methods.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/named_scope_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 2762afc921..c886160af3 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -45,6 +45,15 @@ class NamedScopeTest < ActiveRecord::TestCase
assert_equal Topic.average(:replies_count), Topic.base.average(:replies_count)
end
+ def test_method_missing_priority_when_delegating
+ klazz = Class.new(ActiveRecord::Base) do
+ self.table_name = "topics"
+ scope :since, Proc.new { where('written_on >= ?', Time.now - 1.day) }
+ scope :to, Proc.new { where('written_on <= ?', Time.now) }
+ end
+ assert_equal klazz.to.since.all, klazz.since.to.all
+ end
+
def test_scope_should_respond_to_own_methods_and_methods_of_the_proxy
assert Topic.approved.respond_to?(:limit)
assert Topic.approved.respond_to?(:count)