about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-10 21:45:54 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-10 22:08:00 +0000
commitee0088ea9906701f0c89e89ce78acd9d4820ee65 (patch)
tree979d21bfb1f5cb55561b4b57f49469ccbf3f5e86 /t
parent5e8979ad38efdc4de3a69cc53aea33710d478406 (diff)
downloadunicorn-ee0088ea9906701f0c89e89ce78acd9d4820ee65.tar.gz
Diffstat (limited to 't')
-rwxr-xr-xt/t0302-rails3-alt-working_directory.sh32
-rw-r--r--t/t0303-rails3-alt-working_directory_config.ru.sh48
2 files changed, 80 insertions, 0 deletions
diff --git a/t/t0302-rails3-alt-working_directory.sh b/t/t0302-rails3-alt-working_directory.sh
new file mode 100755
index 0000000..0a8894e
--- /dev/null
+++ b/t/t0302-rails3-alt-working_directory.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+. ./test-rails3.sh
+
+t_plan 3 "Rails 3 (beta) inside alt working_directory (no config.ru)"
+
+t_begin "setup and start" && {
+        unicorn_setup
+        rails3_app=$(cd rails3-app && pwd)
+        rm -rf $t_pfx.app
+        mkdir $t_pfx.app
+        cd $t_pfx.app
+        ( cd $rails3_app && tar cf - . ) | tar xf -
+        rm config.ru
+        $RAKE db:sessions:create
+        $RAKE db:migrate
+        unicorn_setup
+        rm $pid
+        echo "working_directory '$t_pfx.app'" >> $unicorn_config
+        cd /
+        unicorn_rails -D -c $unicorn_config
+        unicorn_wait_start
+}
+
+t_begin "static file serving works" && {
+        test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_done
diff --git a/t/t0303-rails3-alt-working_directory_config.ru.sh b/t/t0303-rails3-alt-working_directory_config.ru.sh
new file mode 100644
index 0000000..b41215e
--- /dev/null
+++ b/t/t0303-rails3-alt-working_directory_config.ru.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+. ./test-rails3.sh
+
+t_plan 4 "Rails 3 (beta) inside alt working_directory (w/ config.ru)"
+
+t_begin "setup and start" && {
+        unicorn_setup
+        rtmpfiles unicorn_config_tmp
+        rails3_app=$(cd rails3-app && pwd)
+        rm -rf $t_pfx.app
+        mkdir $t_pfx.app
+        cd $t_pfx.app
+        ( cd $rails3_app && tar cf - . ) | tar xf -
+        $RAKE db:sessions:create
+        $RAKE db:migrate
+        unicorn_setup
+        rm $pid
+
+        echo "#\\--daemonize --host $host --port $port" \
+             >> $t_pfx.app/config.ru
+
+        # we have --host/--port in config.ru instead
+        grep -v ^listen $unicorn_config |
+          grep -v ^pid > $unicorn_config_tmp
+        echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
+        cd /
+        unicorn_rails -c $unicorn_config_tmp
+}
+
+t_begin "pids in the right place" && {
+        if test -e $pid
+        then
+                die "pid=$pid not expected"
+        fi
+
+        unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid"
+        unicorn_pid=$(cat $unicorn_rails_pid)
+}
+
+t_begin "static file serving works" && {
+        test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_done