Browse Source

Merge pull request #2085 from Zloy/round-14

Fixes #2084 Sinatra tests fail due to missing mandatory headers Date …
Nate 9 years ago
parent
commit
0b53a4d77a

+ 7 - 1
frameworks/Ruby/sinatra/hello_world.rb

@@ -28,6 +28,12 @@ set :database, db_config.merge(:adapter => adapter, :host => ENV['DB_HOST'])
 settings.filters[:before].clear
 settings.filters[:after].clear
 
+after do
+  # Add mandatory HTTP headers to every response
+  response['Server'] ||= ENV['WEB_SERVER'].freeze
+  response['Date'] ||= Time.now.to_s
+end
+
 class World < ActiveRecord::Base
   self.table_name = "World"
 end
@@ -41,7 +47,7 @@ get '/json' do
 end
 
 get '/plaintext' do
-  content_type 'text/plain'
+  response['Content-type'] = 'text/plain'
   'Hello, World!'
 end
 

+ 1 - 1
frameworks/Ruby/sinatra/run_jruby_puma.sh

@@ -4,4 +4,4 @@ fw_depends rvm jruby-1.7
 
 rvm jruby-$JRUBY_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec puma -C config/puma.rb &
+WEB_SERVER=Puma DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec puma -C config/puma.rb &

+ 1 - 1
frameworks/Ruby/sinatra/run_mri_puma.sh

@@ -4,4 +4,4 @@ fw_depends rvm ruby-2.0
 
 rvm ruby-$MRI_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec puma -C config/puma.rb -w 8 --preload &
+WEB_SERVER=Puma DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec puma -C config/puma.rb -w 8 --preload &

+ 1 - 1
frameworks/Ruby/sinatra/run_rbx_puma.sh

@@ -4,4 +4,4 @@ fw_depends rvm rbx-2.4
 
 rvm rbx-$RBX_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm rbx-$RBX_VERSION do bundle exec puma &
+WEB_SERVER=Puma DB_HOST=${DBHOST} rvm rbx-$RBX_VERSION do bundle exec puma &

+ 1 - 1
frameworks/Ruby/sinatra/run_thin.sh

@@ -4,4 +4,4 @@ fw_depends rvm ruby-2.0
 
 rvm ruby-$MRI_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec thin start -C config/thin.yml &
+WEB_SERVER=Thin DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec thin start -C config/thin.yml &

+ 1 - 1
frameworks/Ruby/sinatra/run_torqbox.sh

@@ -4,4 +4,4 @@ fw_depends rvm jruby-1.7
 
 rvm jruby-$JRUBY_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec torqbox -b 0.0.0.0 -E production &
+WEB_SERVER=Torqbox DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec torqbox -b 0.0.0.0 -E production &

+ 1 - 1
frameworks/Ruby/sinatra/run_trinidad.sh

@@ -4,4 +4,4 @@ fw_depends rvm jruby-1.7
 
 rvm jruby-$JRUBY_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path=vendor/bundle
 
-DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec trinidad --config config/trinidad.yml &
+WEB_SERVER=Trinidad DB_HOST=${DBHOST} rvm jruby-$JRUBY_VERSION do bundle exec trinidad --config config/trinidad.yml &

+ 1 - 1
frameworks/Ruby/sinatra/run_unicorn.sh

@@ -8,4 +8,4 @@ rvm ruby-$MRI_VERSION do bundle install --jobs=4 --gemfile=$TROOT/Gemfile --path
 
 nginx -c $TROOT/config/nginx.conf
 
-DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec unicorn -E production -c config/unicorn.rb &
+WEB_SERVER=Unicorn DB_HOST=${DBHOST} rvm ruby-$MRI_VERSION do bundle exec unicorn -E production -c config/unicorn.rb &