diff --git a/lib/draper/collection_decorator.rb b/lib/draper/collection_decorator.rb index 392cf38..5a07fca 100644 --- a/lib/draper/collection_decorator.rb +++ b/lib/draper/collection_decorator.rb @@ -47,18 +47,6 @@ module Draper @decorated_collection ||= object.map{|item| decorate_item(item)} end - # Delegated to the decorated collection when using the block form - # (`Enumerable#find`) or to the decorator class if not - # (`ActiveRecord::FinderMethods#find`) - def find(*args, &block) - if block_given? - decorated_collection.find(*args, &block) - else - ActiveSupport::Deprecation.warn("Using ActiveRecord's `find` on a CollectionDecorator is deprecated. Call `find` on a model, and then decorate the result", caller) - decorate_item(object.find(*args)) - end - end - def to_s "#<#{self.class.name} of #{decorator_class || "inferred decorators"} for #{object.inspect}>" end diff --git a/spec/draper/collection_decorator_spec.rb b/spec/draper/collection_decorator_spec.rb index a0eac1c..2aa994d 100644 --- a/spec/draper/collection_decorator_spec.rb +++ b/spec/draper/collection_decorator_spec.rb @@ -116,30 +116,6 @@ module Draper end end - describe "#find" do - context "with a block" do - it "decorates Enumerable#find" do - decorator = CollectionDecorator.new([], :with => NullDecorator) - - decorator.decorated_collection.should_receive(:find).and_return(:delegated) - expect(decorator.find{|p| p.title == "title"}).to be :delegated - end - end - - context "without a block" do - it "decorates object.find" do - object = [] - found = double(decorate: :decorated) - decorator = CollectionDecorator.new(object, :with => NullDecorator) - - object.should_receive(:find).and_return(found) - ActiveSupport::Deprecation.silence do - expect(decorator.find(1)).to be :decorated - end - end - end - end - describe "#to_ary" do # required for `render @collection` in Rails it "delegates to the decorated collection" do @@ -202,7 +178,7 @@ module Draper decorator = CollectionDecorator.new(object, :with => ProductDecorator) other = object.dup - decorator << Product.new.decorate + decorator << ProductDecorator.new(Product.new) expect(decorator == other).to be_falsey end end @@ -217,14 +193,6 @@ module Draper end end - context "when :with option was not given" do - it "returns a string representation of the collection decorator" do - decorator = CollectionDecorator.new(["a", "b", "c"], :with => NullDecorator) - - expect(decorator.to_s).to eq '#' - end - end - context "for a custom subclass" do it "uses the custom class name" do decorator = ProductsDecorator.new([], :with => ProductDecorator)