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

Fix FCGI dispatching tests

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Mike Gunderloy 2008-12-28 20:31:33 -06:00 committed by Pratik Naik
parent c20c72e3d9
commit 36af857c43

View file

@ -1,10 +1,9 @@
require 'abstract_unit'
begin
require 'action_controller'
require 'fcgi_handler'
module ActionController; module Routing; module Routes; end end end
class RailsFCGIHandlerTest < Test::Unit::TestCase
def setup
@log = StringIO.new
@ -131,19 +130,11 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
end
end
class ::Dispatcher
class << self
attr_accessor :signal
alias_method :old_dispatch, :dispatch
def dispatch(cgi)
signal ? Process.kill(signal, $$) : old_dispatch
end
end
end
def setup
@log = StringIO.new
@handler = RailsFCGIHandler.new(@log)
@dispatcher = mock
Dispatcher.stubs(:new).returns(@dispatcher)
end
def test_interrupted_via_HUP_when_not_in_request
@ -159,19 +150,6 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
assert_equal :reload, @handler.when_ready
end
def test_interrupted_via_HUP_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
Dispatcher.expects(:signal).times(2).returns('HUP')
@handler.expects(:reload!).once
@handler.expects(:close_connection).never
@handler.expects(:exit).never
@handler.process!
assert_equal :reload, @handler.when_ready
end
def test_interrupted_via_USR1_when_not_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
@ -186,19 +164,6 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
assert_nil @handler.when_ready
end
def test_interrupted_via_USR1_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
Dispatcher.expects(:signal).times(2).returns('USR1')
@handler.expects(:reload!).never
@handler.expects(:close_connection).with(cgi).once
@handler.expects(:exit).never
@handler.process!
assert_equal :exit, @handler.when_ready
end
def test_restart_via_USR2_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
@ -217,7 +182,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
def test_interrupted_via_TERM
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
Dispatcher.expects(:signal).times(2).returns('TERM')
::Rack::Handler::FastCGI.expects(:serve).once.returns('TERM')
@handler.expects(:reload!).never
@handler.expects(:close_connection).never
@ -238,7 +203,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
cgi = mock
error = RuntimeError.new('foo')
FCGI.expects(:each_cgi).once.yields(cgi)
Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
::Rack::Handler::FastCGI.expects(:serve).once.raises(error)
@handler.expects(:dispatcher_error).with(error, regexp_matches(/^unhandled/))
@handler.process!
end
@ -254,7 +219,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
cgi = mock
error = SignalException.new('USR2')
FCGI.expects(:each_cgi).once.yields(cgi)
Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
::Rack::Handler::FastCGI.expects(:serve).once.raises(error)
@handler.expects(:dispatcher_error).with(error, regexp_matches(/^stopping/))
@handler.process!
end
@ -284,7 +249,7 @@ class RailsFCGIHandlerPeriodicGCTest < Test::Unit::TestCase
cgi = mock
FCGI.expects(:each_cgi).times(10).yields(cgi)
Dispatcher.expects(:dispatch).times(10).with(cgi)
Dispatcher.expects(:new).times(10)
@handler.expects(:run_gc!).never
9.times { @handler.process! }