1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/controller/dispatcher_test.rb

60 lines
1.1 KiB
Ruby
Raw Normal View History

require 'abstract_unit'
# Ensure deprecated dispatcher works
class DeprecatedDispatcherTest < ActiveSupport::TestCase
class DummyApp
def call(env)
[200, {}, 'response']
end
end
def setup
ActionDispatch::Callbacks.reset_callbacks(:prepare)
ActionDispatch::Callbacks.reset_callbacks(:call)
end
def test_assert_deprecated_to_prepare
a = nil
assert_deprecated do
ActionController::Dispatcher.to_prepare { a = 1 }
end
assert_nil a
dispatch
assert_equal 1, a
end
def test_assert_deprecated_before_dispatch
a = nil
assert_deprecated do
ActionController::Dispatcher.before_dispatch { a = 1 }
end
assert_nil a
dispatch
assert_equal 1, a
end
def test_assert_deprecated_after_dispatch
a = nil
assert_deprecated do
ActionController::Dispatcher.after_dispatch { a = 1 }
end
assert_nil a
dispatch
assert_equal 1, a
end
private
def dispatch(cache_classes = true)
@dispatcher ||= ActionDispatch::Callbacks.new(DummyApp.new, !cache_classes)
@dispatcher.call({'rack.input' => StringIO.new('')})
end
end