Created
April 10, 2013 10:02
-
-
Save tjormola/5353359 to your computer and use it in GitHub Desktop.
A test script for https://github.com/rails/rails/pull/10114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Initialize | |
RAILS_BASE=/tmp/rails | |
APP_NAME=foo | |
WAIT_TIME=2 | |
set -e -o verbose -o xtrace | |
# Display system info | |
lsb_release -a | |
uname -a | |
ruby -v | |
gem -v | |
# Reset and setup Rails | |
rm -rf $RAILS_BASE | |
mkdir -p $RAILS_BASE/gem | |
export GEM_HOME=$RAILS_BASE/gem | |
export PATH=$GEM_HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin | |
gem install rails --no-ri --no-rdoc | |
cd $RAILS_BASE | |
rails new $APP_NAME | |
cd $APP_NAME | |
# Configure relative URL root support in Rails routing | |
head -n1 config/routes.rb > config/routes.rb.new | |
echo "scope (Rails.application.config.relative_url_root || '/') do" >> config/routes.rb.new | |
tail -n+2 config/routes.rb >> config/routes.rb.new | |
echo "end" >> config/routes.rb.new | |
mv config/routes.rb.new config/routes.rb | |
# Development mode, no root URL -> works ok | |
RAILS_ENV=development rails server -d | |
sleep $WAIT_TIME | |
wget http://127.0.0.1:3000 -O /dev/stdout | grep '<title>' | |
kill -9 `cat tmp/pids/server.pid` | |
# Production mode, no root URL -> returns 404 because static files not served in production mode | |
RAILS_ENV=production rails server -d | |
sleep $WAIT_TIME | |
wget http://127.0.0.1:3000 -O /dev/stdout | grep '<title>' || true | |
kill -9 `cat tmp/pids/server.pid` | |
# Development mode, root URL set -> doesn't work, returns 404 even though should return the content of public/index.html | |
RAILS_ENV=development RAILS_RELATIVE_URL_ROOT=/$APP_NAME rails server -d | |
sleep $WAIT_TIME | |
wget http://127.0.0.1:3000/$APP_NAME/ -O /dev/stdout | grep '<title>' || true | |
kill -9 `cat tmp/pids/server.pid` | |
# Production mode, root URL set -> returns 404 because static files not served in production mode | |
RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/$APP_NAME rails server -d | |
sleep $WAIT_TIME | |
wget http://127.0.0.1:3000/$APP_NAME/ -O /dev/stdout | grep '<title>' || true | |
kill -9 `cat tmp/pids/server.pid` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment