Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

append _collection for uncountable resources

  • Loading branch information...
commit 30d24385cea8a3b935c992c6cd837af5f49e680f 1 parent f346975
@senny senny authored
View
1  lib/decent_exposure/default_exposure.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
View
12 spec/lib/rails_integration_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.