From 56b0c0c3d26304beeef54d8fe95bead97424f147 Mon Sep 17 00:00:00 2001 From: Micah Chalmer Date: Thu, 6 Jun 2013 23:03:36 -0400 Subject: Make -N/--no-default-middleware option work This fixes the -N (a.k.a. --no-defaut-middleware) option, which was not working. The problem was that Unicorn::Configurator::RACKUP is cleared before the lambda returned by Unicorn.builder is run, which means that checking whether the :no_default_middleware option was set from the lambda could not detect anything. This patch copies it to a local variable that won't get clobbered, restoring the feature. [ew: squashed test commit into the fix, whitespace fixes] Signed-off-by: Eric Wong --- t/fails-rack-lint.ru | 5 +++++ t/t0300-no-default-middleware.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 t/fails-rack-lint.ru create mode 100644 t/t0300-no-default-middleware.sh (limited to 't') 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 -- cgit v1.2.3-24-ge0c7