Permalink
Browse files

append _collection for uncountable resources

  • Loading branch information...
senny committed Oct 12, 2011
1 parent f346975 commit 30d24385cea8a3b935c992c6cd837af5f49e680f
Showing with 13 additions and 0 deletions.
  1. +1 −0 lib/decent_exposure/default_exposure.rb
  2. +12 −0 spec/lib/rails_integration_spec.rb
@@ -9,6 +9,7 @@ def self.included(klass)
end
klass.default_exposure do |name|
collection = name.to_s.pluralize
+ collection += "_collection" if name.to_s == collection
if respond_to?(collection) && collection != name.to_s && send(collection).respond_to?(:scoped)
proxy = send(collection)
else
@@ -105,6 +105,18 @@ def initialize(*args); end
instance.person
end
end
+
+ context 'appends _collection to uncountable collections' do
+ let(:collection){ mock(:scoped => [self]) }
+
+ before{ controller.expose(:sheep) }
+
+ it 'uses the existing collection method' do
+ instance.stubs(:sheep_collection).returns(collection)
+ collection.expects(:new)
+ instance.sheep
+ end
+ end
end
context 'when either :resource_id or :id are present in params' do

0 comments on commit 30d2438

Please sign in to comment.