From 0b8b582e0668416c6e6760e97a64b9fa3507782c Mon Sep 17 00:00:00 2001 From: Duncan Beevers Date: Sun, 11 May 2008 20:33:25 +0100 Subject: Add test for named_scope#proxy_options. [#97 state:resolved] --- activerecord/lib/active_record/named_scope.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 81b99f8e96..d43ebefc3b 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -71,6 +71,18 @@ module ActiveRecord # end # end # + # + # For testing complex named scopes, you can examine the scoping options using the + # proxy_options method on the proxy itself. + # + # class Shirt < ActiveRecord::Base + # named_scope :colored, lambda { |color| + # { :conditions => { :color => color } } + # } + # end + # + # expected_options = { :conditions => { :colored => 'red' } } + # assert_equal expected_options, Shirt.colored('red').proxy_options def named_scope(name, options = {}, &block) scopes[name] = lambda do |parent_scope, *args| Scope.new(parent_scope, case options -- cgit v1.2.3