File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,18 @@ def scopes
71
71
# end
72
72
# end
73
73
#
74
+ #
75
+ # For testing complex named scopes, you can examine the scoping options using the
76
+ # <tt>proxy_options</tt> method on the proxy itself.
77
+ #
78
+ # class Shirt < ActiveRecord::Base
79
+ # named_scope :colored, lambda { |color|
80
+ # { :conditions => { :color => color } }
81
+ # }
82
+ # end
83
+ #
84
+ # expected_options = { :conditions => { :colored => 'red' } }
85
+ # assert_equal expected_options, Shirt.colored('red').proxy_options
74
86
def named_scope ( name , options = { } , &block )
75
87
scopes [ name ] = lambda do |parent_scope , *args |
76
88
Scope . new ( parent_scope , case options
Original file line number Diff line number Diff line change @@ -112,4 +112,10 @@ def test_active_records_have_scope_named__scoped__
112
112
113
113
assert_equal Topic . find ( :all , scope ) , Topic . scoped ( scope )
114
114
end
115
+
116
+ def test_proxy_options
117
+ expected_proxy_options = { :conditions => { :approved => true } }
118
+ assert_equal expected_proxy_options , Topic . approved . proxy_options
119
+ end
120
+
115
121
end
You can’t perform that action at this time.
0 commit comments