diff options
| -rw-r--r-- | actionpack/lib/action_dispatch/middleware/callbacks.rb | 8 | ||||
| -rw-r--r-- | actionpack/test/dispatch/callbacks_test.rb | 12 | 
2 files changed, 11 insertions, 9 deletions
| diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index 5776a7bb27..4d038c29f2 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module/delegation' +  module ActionDispatch    # Provide callbacks to be executed before and after the request dispatch.    class Callbacks @@ -5,10 +7,8 @@ module ActionDispatch      define_callbacks :call, :rescuable => true -    def self.to_prepare(*args, &block) -      ActiveSupport::Deprecation.warn "ActionDispatch::Callbacks.to_prepare is deprecated. " << -        "Please use ActionDispatch::Reloader.to_prepare instead." -      ActionDispatch::Reloader.to_prepare(*args, &block) +    class << self +      delegate :to_prepare, :to_cleanup, :to => "ActionDispatch::Reloader"      end      def self.before(*args, &block) diff --git a/actionpack/test/dispatch/callbacks_test.rb b/actionpack/test/dispatch/callbacks_test.rb index 5becb621de..eed2eca2ab 100644 --- a/actionpack/test/dispatch/callbacks_test.rb +++ b/actionpack/test/dispatch/callbacks_test.rb @@ -29,14 +29,16 @@ class DispatcherTest < ActiveSupport::TestCase      assert_equal 4, Foo.b    end -  def test_to_prepare_deprecation -    prepared = false -    assert_deprecated do -      ActionDispatch::Callbacks.to_prepare { prepared = true } -    end +  def test_to_prepare_and_cleanup_delegation +    prepared = cleaned = false +    ActionDispatch::Callbacks.to_prepare { prepared = true } +    ActionDispatch::Callbacks.to_prepare { cleaned = true }      ActionDispatch::Reloader.prepare!      assert prepared + +    ActionDispatch::Reloader.cleanup! +    assert cleaned    end    private | 
