Permalink
Browse files

Merge pull request #500 from drueck/collection-decorated-with

Decorated collection also responds to decorated_with?
  • Loading branch information...
2 parents 07e19cc + a6a122b commit dc430b3e82de0d9cae86f7297f816e5b69d9ca58 @steveklabnik steveklabnik committed Mar 14, 2013
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/draper/collection_decorator.rb
  2. +9 −0 spec/draper/collection_decorator_spec.rb
@@ -66,6 +66,8 @@ def decorated?
true
end
+ alias_method :decorated_with?, :instance_of?
+
def kind_of?(klass)
decorated_collection.kind_of?(klass) || super
end
@@ -243,6 +243,15 @@ module Draper
end
end
+ describe '#decorated_with?' do
+ it "checks if a decorator has been applied to a collection" do
+ decorator = ProductsDecorator.new([Product.new])
+
+ expect(decorator).to be_decorated_with ProductsDecorator
+ expect(decorator).not_to be_decorated_with OtherDecorator
+ end
+ end
+
describe '#kind_of?' do
it 'asks the kind of its decorated collection' do
decorator = ProductsDecorator.new([])

0 comments on commit dc430b3

Please sign in to comment.