提交 20d69384 编写于 作者: J Joshua Peek

Rewrite FCGI handler test

上级 7de5f69c
......@@ -216,7 +216,9 @@ def mark_features!
def restore!
$".replace @features
Dispatcher.reset_application!
# TODO: Reloading the application should be the "Application"s
# responsibility
ActionDispatch::Callbacks.new(lambda {}, true)
ActionController::Routing::Routes.reload
end
......
......@@ -25,15 +25,3 @@
else
RAILS_ROOT = File.dirname(__FILE__)
end
def uses_gem(gem_name, test_name, version = '> 0')
begin
require gem_name.to_s
rescue LoadError
gem gem_name.to_s, version
require gem_name.to_s
end
yield
rescue LoadError
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
end
require 'abstract_unit'
require 'isolation/abstract_unit'
require 'mocha'
uses_gem "fcgi", "0.8.7" do
begin
require 'action_controller'
require 'rails/fcgi_handler'
module Rails
def self.application
ActionController::Routing::Routes
end
begin
require 'fcgi'
rescue LoadError
gem 'fcgi', '0.8.7'
require 'fcgi'
end
class RailsFCGIHandlerTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
require "#{rails_root}/config/environment"
require 'rails/fcgi_handler'
@log = StringIO.new
@handler = RailsFCGIHandler.new(@log)
end
......@@ -87,7 +94,6 @@ def test_reload
assert_nil @handler.when_ready
end
def test_reload_runs_gc_when_gc_request_period_set
@handler.expects(:run_gc!)
@handler.expects(:restore!)
......@@ -111,7 +117,6 @@ def test_restart!
def test_restore!
$".expects(:replace)
Dispatcher.expects(:reset_application!)
ActionController::Routing::Routes.expects(:reload)
@handler.send(:restore!)
end
......@@ -127,17 +132,24 @@ def test_uninterrupted_processing
end
end
class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
class ::RailsFCGIHandler
attr_accessor :signal
alias_method :old_gc_countdown, :gc_countdown
def gc_countdown
signal ? Process.kill(signal, $$) : old_gc_countdown
end
end
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
require "#{rails_root}/config/environment"
require 'rails/fcgi_handler'
::RailsFCGIHandler.class_eval do
attr_accessor :signal
alias_method :old_gc_countdown, :gc_countdown
def gc_countdown
signal ? Process.kill(signal, $$) : old_gc_countdown
end
end
@log = StringIO.new
@handler = RailsFCGIHandler.new(@log)
@dispatcher = mock
......@@ -232,9 +244,16 @@ def test_signal_exception_in_dispatcher
end
end
class RailsFCGIHandlerPeriodicGCTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
require "#{rails_root}/config/environment"
require 'rails/fcgi_handler'
@log = StringIO.new
end
......@@ -265,4 +284,7 @@ def test_periodic_gc
assert_nil @handler.when_ready
end
end
end # uses_gem "fcgi"
rescue LoadError
$stderr.puts 'Skipping fcgi tests. `gem install fcgi` and try again.'
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册