diff --git a/lib/draper/collection_decorator.rb b/lib/draper/collection_decorator.rb index 2f3102d..b3e4cee 100644 --- a/lib/draper/collection_decorator.rb +++ b/lib/draper/collection_decorator.rb @@ -42,17 +42,7 @@ 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 + delegate :find, to: :decorated_collection def to_s "#<#{self.class.name} of #{decorator_class || "inferred decorators"} for #{object.inspect}>" diff --git a/lib/draper/helper_proxy.rb b/lib/draper/helper_proxy.rb index 73b147e..dd590be 100644 --- a/lib/draper/helper_proxy.rb +++ b/lib/draper/helper_proxy.rb @@ -4,9 +4,7 @@ module Draper class HelperProxy # @overload initialize(view_context) - def initialize(view_context = nil) - view_context ||= current_view_context # backwards compatibility - + def initialize(view_context) @view_context = view_context end @@ -35,10 +33,5 @@ module Draper view_context.send(name, *args, &block) end end - - def current_view_context - ActiveSupport::Deprecation.warn("wrong number of arguments (0 for 1) passed to Draper::HelperProxy.new", caller[1..-1]) - Draper::ViewContext.current.view_context - end end end diff --git a/lib/draper/test/devise_helper.rb b/lib/draper/test/devise_helper.rb index 4ca7524..e6b1b38 100644 --- a/lib/draper/test/devise_helper.rb +++ b/lib/draper/test/devise_helper.rb @@ -1,14 +1,7 @@ module Draper module DeviseHelper def sign_in(resource_or_scope, resource = nil) - scope = begin - Devise::Mapping.find_scope!(resource_or_scope) - rescue RuntimeError => e - # Draper 1.0 didn't require the mapping to exist - ActiveSupport::Deprecation.warn("#{e.message}.\nUse `sign_in :user, mock_user` instead.", caller) - :user - end - + scope = Devise::Mapping.find_scope!(resource_or_scope) _stub_current_scope scope, resource || resource_or_scope end diff --git a/lib/draper/view_context.rb b/lib/draper/view_context.rb index f11ea1e..9634d25 100644 --- a/lib/draper/view_context.rb +++ b/lib/draper/view_context.rb @@ -82,23 +82,5 @@ module Draper def self.build_strategy @build_strategy ||= Draper::ViewContext::BuildStrategy.new(:full) end - - # @deprecated Use {controller} instead. - def self.current_controller - ActiveSupport::Deprecation.warn("Draper::ViewContext.current_controller is deprecated (use controller instead)", caller) - self.controller || ApplicationController.new - end - - # @deprecated Use {controller=} instead. - def self.current_controller=(controller) - ActiveSupport::Deprecation.warn("Draper::ViewContext.current_controller= is deprecated (use controller= instead)", caller) - self.controller = controller - end - - # @deprecated Use {build} instead. - def self.build_view_context - ActiveSupport::Deprecation.warn("Draper::ViewContext.build_view_context is deprecated (use build instead)", caller) - build - end end end diff --git a/spec/draper/collection_decorator_spec.rb b/spec/draper/collection_decorator_spec.rb index d8b42ec..b704fe1 100644 --- a/spec/draper/collection_decorator_spec.rb +++ b/spec/draper/collection_decorator_spec.rb @@ -121,26 +121,11 @@ module Draper end describe "#find" do - context "with a block" do - it "decorates Enumerable#find" do - decorator = CollectionDecorator.new([]) + it "decorates Enumerable#find" do + decorator = CollectionDecorator.new([]) - expect(decorator.decorated_collection).to 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) - - expect(object).to receive(:find).and_return(found) - ActiveSupport::Deprecation.silence do - expect(decorator.find(1)).to be :decorated - end - end + expect(decorator.decorated_collection).to receive(:find).and_return(:delegated) + expect(decorator.find{|p| p.title == "title"}).to be :delegated end end diff --git a/spec/dummy/spec/decorators/devise_spec.rb b/spec/dummy/spec/decorators/devise_spec.rb index 6480751..ee7067b 100644 --- a/spec/dummy/spec/decorators/devise_spec.rb +++ b/spec/dummy/spec/decorators/devise_spec.rb @@ -51,14 +51,5 @@ if defined?(Devise) expect(helper.current_user).to be_nil end - - it "is backwards-compatible" do - user = double("User") - ActiveSupport::Deprecation.silence do - sign_in user - end - - expect(helper.current_user).to be user - end end end diff --git a/spec/dummy/test/decorators/minitest/devise_test.rb b/spec/dummy/test/decorators/minitest/devise_test.rb index f27af83..8e55dd6 100644 --- a/spec/dummy/test/decorators/minitest/devise_test.rb +++ b/spec/dummy/test/decorators/minitest/devise_test.rb @@ -51,14 +51,5 @@ if defined?(Devise) assert helper.current_user.nil? end - - it "is backwards-compatible" do - user = Object.new - ActiveSupport::Deprecation.silence do - sign_in user - end - - assert_same user, helper.current_user - end end end diff --git a/spec/dummy/test/decorators/test_unit/devise_test.rb b/spec/dummy/test/decorators/test_unit/devise_test.rb index d50adea..36a5c0c 100644 --- a/spec/dummy/test/decorators/test_unit/devise_test.rb +++ b/spec/dummy/test/decorators/test_unit/devise_test.rb @@ -51,14 +51,5 @@ if defined?(Devise) assert helper.current_user.nil? end - - def test_backwards_compatibility - user = Object.new - ActiveSupport::Deprecation.silence do - sign_in user - end - - assert_same user, helper.current_user - end end end