diff options
-rw-r--r-- | lib/unicorn.rb | 6 | ||||
-rw-r--r-- | t/fails-rack-lint.ru | 5 | ||||
-rw-r--r-- | t/t0300-no-default-middleware.sh | 15 |
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index f0ceffe..2535159 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -35,6 +35,10 @@ module Unicorn # allow Configurator to parse cli switches embedded in the ru file op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op) + # Op is going to get cleared before the returned lambda is called, so + # save this value so that it's still there when we need it: + no_default_middleware = op[:no_default_middleware] + # always called after config file parsing, may be called after forking lambda do || inner_app = case ru @@ -49,7 +53,7 @@ module Unicorn pp({ :inner_app => inner_app }) if $DEBUG - return inner_app if op[:no_default_middleware] + return inner_app if no_default_middleware # return value, matches rackup defaults based on env # Unicorn does not support persistent connections, but Rainbows! diff --git a/t/fails-rack-lint.ru b/t/fails-rack-lint.ru new file mode 100644 index 0000000..82bfb5f --- /dev/null +++ b/t/fails-rack-lint.ru @@ -0,0 +1,5 @@ +# This rack app returns an invalid status code, which will cause +# Rack::Lint to throw an exception if it is present. This +# is used to check whether Rack::Lint is in the stack or not. + +run lambda {|env| return [42, {}, ["Rack::Lint wasn't there if you see this"]]} diff --git a/t/t0300-no-default-middleware.sh b/t/t0300-no-default-middleware.sh new file mode 100644 index 0000000..c017c16 --- /dev/null +++ b/t/t0300-no-default-middleware.sh @@ -0,0 +1,15 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 2 "test the -N / --no-default-middleware option" + +t_begin "setup and start" && { + unicorn_setup + unicorn -N -D -c $unicorn_config fails-rack-lint.ru + unicorn_wait_start +} + +t_begin "check exit status with Rack::Lint not present" && { + test 42 -eq "$(curl -sf -o/dev/null -w'%{http_code}' http://$listen/)" +} + +t_done |