2008-01-05 08:33:00 -05:00
|
|
|
require 'abstract_unit'
|
2007-05-29 17:49:37 -04:00
|
|
|
|
|
|
|
require 'action_controller' # console_app uses 'action_controller/integration'
|
|
|
|
|
2007-09-25 21:24:07 -04:00
|
|
|
unless defined? ApplicationController
|
|
|
|
class ApplicationController < ActionController::Base; end
|
2008-12-15 17:33:31 -05:00
|
|
|
ActionController::Base.session_store = nil
|
2007-09-25 21:24:07 -04:00
|
|
|
end
|
|
|
|
|
2007-05-29 17:49:37 -04:00
|
|
|
require 'dispatcher'
|
|
|
|
require 'console_app'
|
|
|
|
|
|
|
|
# console_app sets Test::Unit.run to work around the at_exit hook in test/unit, which kills IRB
|
2009-02-27 15:19:23 -05:00
|
|
|
if Test::Unit.respond_to?(:run=)
|
|
|
|
Test::Unit.run = false
|
|
|
|
|
|
|
|
class ConsoleAppTest < Test::Unit::TestCase
|
|
|
|
def test_app_method_should_return_integration_session
|
|
|
|
assert_nothing_thrown do
|
|
|
|
console_session = app
|
|
|
|
assert_not_nil console_session
|
|
|
|
assert_instance_of ActionController::Integration::Session,
|
|
|
|
console_session
|
|
|
|
end
|
2009-01-02 11:31:21 -05:00
|
|
|
end
|
|
|
|
|
2009-02-27 15:19:23 -05:00
|
|
|
def test_reload_should_fire_preparation_callbacks
|
|
|
|
a = b = c = nil
|
2007-05-29 17:49:37 -04:00
|
|
|
|
2009-02-27 15:19:23 -05:00
|
|
|
Dispatcher.to_prepare { a = b = c = 1 }
|
|
|
|
Dispatcher.to_prepare { b = c = 2 }
|
|
|
|
Dispatcher.to_prepare { c = 3 }
|
|
|
|
ActionController::Routing::Routes.expects(:reload)
|
2007-05-29 17:49:37 -04:00
|
|
|
|
2009-02-27 15:19:23 -05:00
|
|
|
reload!
|
2007-05-29 17:49:37 -04:00
|
|
|
|
2009-02-27 15:19:23 -05:00
|
|
|
assert_equal 1, a
|
|
|
|
assert_equal 2, b
|
|
|
|
assert_equal 3, c
|
|
|
|
end
|
2007-05-29 17:49:37 -04:00
|
|
|
end
|
|
|
|
end
|