diff options
-rw-r--r-- | railties/test/fcgi_dispatcher_test.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/railties/test/fcgi_dispatcher_test.rb b/railties/test/fcgi_dispatcher_test.rb index 7e84402a21..6134211022 100644 --- a/railties/test/fcgi_dispatcher_test.rb +++ b/railties/test/fcgi_dispatcher_test.rb @@ -59,11 +59,12 @@ class RailsFCGIHandlerTest < Test::Unit::TestCase @handler.process! end - def test_restart_handler + def test_restart_handler_outside_request @handler.expects(:dispatcher_log).with(:info, "asked to restart ASAP") + @handler.expects(:restart!).once @handler.send(:restart_handler, nil) - assert_equal :restart, @handler.when_ready + assert_equal nil, @handler.when_ready end def test_install_signal_handler_should_log_on_bad_signal @@ -131,7 +132,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_HUP_when_not_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - @handler.expects(:gc_countdown).returns { Process.kill 'HUP', $$ } + @handler.expects(:gc_countdown).returns(lambda { Process.kill 'HUP', $$ } ) @handler.expects(:reload!).once @handler.expects(:close_connection).never @@ -144,7 +145,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_HUP_when_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'HUP', $$ } + Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'HUP', $$ } ) @handler.expects(:reload!).once @handler.expects(:close_connection).never @@ -157,7 +158,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_USR1_when_not_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - @handler.expects(:gc_countdown).returns { Process.kill 'USR1', $$ } + @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR1', $$ } ) @handler.expects(:exit_handler).never @handler.expects(:reload!).never @@ -171,7 +172,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_USR1_when_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'USR1', $$ } + Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'USR1', $$ } ) @handler.expects(:reload!).never @handler.expects(:close_connection).with(cgi).once @@ -181,10 +182,25 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase assert_equal :exit, @handler.when_ready end + def test_restart_via_USR2_when_in_request + cgi = mock + FCGI.expects(:each_cgi).once.yields(cgi) + @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR2', $$ } ) + @handler.expects(:exit_handler).never + + @handler.expects(:reload!).never + @handler.expects(:close_connection).with(cgi).once + @handler.expects(:exit).never + @handler.expects(:restart!).once + + @handler.process! + assert_equal :restart, @handler.when_ready + end + def test_interrupted_via_TERM cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'TERM', $$ } + Dispatcher.expects(:dispatch).with(cgi).returns(lambda { Process.kill 'TERM', $$ }) @handler.expects(:reload!).never @handler.expects(:close_connection).never |