health_check 2.5.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +162 -111
  4. data/CHANGELOG +36 -0
  5. data/README.rdoc +109 -43
  6. data/Rakefile +1 -1
  7. data/Vagrantfile +32 -0
  8. data/config/routes.rb +1 -1
  9. data/health_check.gemspec +7 -6
  10. data/lib/health_check.rb +51 -6
  11. data/lib/health_check/elasticsearch_health_check.rb +15 -0
  12. data/lib/health_check/health_check_controller.rb +32 -25
  13. data/lib/health_check/health_check_routes.rb +1 -1
  14. data/lib/health_check/middleware_health_check.rb +6 -1
  15. data/lib/health_check/rabbitmq_health_check.rb +16 -0
  16. data/lib/health_check/redis_health_check.rb +20 -7
  17. data/lib/health_check/s3_health_check.rb +9 -14
  18. data/lib/health_check/utils.rb +55 -33
  19. data/lib/health_check/version.rb +1 -1
  20. data/test/fake_smtp_server +143 -24
  21. data/test/init_variables +19 -1
  22. data/test/migrate/nine/9_create_countries.rb +1 -1
  23. data/test/migrate/twelve/011_create_roles.roles.rb +1 -1
  24. data/test/migrate/twelve/012_create_users.rb +2 -2
  25. data/test/migrate/twelve/9_create_countries.rb +1 -1
  26. data/test/provision_vagrant +103 -0
  27. data/test/rails_5.0.gemfile +10 -7
  28. data/test/rails_5.1.gemfile +34 -0
  29. data/test/rails_5.2.gemfile +34 -0
  30. data/test/rails_6.0.gemfile +30 -0
  31. data/test/rails_6.1.gemfile +29 -0
  32. data/test/rails_6.2.gemfile +30 -0
  33. data/test/rails_edge.gemfile +14 -9
  34. data/test/setup_railsapp +175 -95
  35. data/test/test_with_railsapp +152 -46
  36. data/test/testurl +9 -0
  37. metadata +45 -22
  38. data/test/rails_4.0.gemfile +0 -33
  39. data/test/rails_4.1.gemfile +0 -33
  40. data/test/rails_4.2.gemfile +0 -30
@@ -0,0 +1,30 @@
1
+ # Gemfile for health_test testing
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
6
+
7
+ gem 'rails', '~> 6.0.0'
8
+ gem 'rake', '>= 0.8.7'
9
+
10
+ gem 'listen', '<3.1.2' # REQUIRED
11
+
12
+ group :development, :test do
13
+ if defined?(JRUBY_VERSION)
14
+ gem 'jruby-openssl'
15
+ gem 'activerecord-jdbcsqlite3-adapter'
16
+ else
17
+ gem 'sqlite3', "~> 1.3.7"
18
+ end
19
+ gem 'shoulda'
20
+ end
21
+
22
+ # redis based checks
23
+ gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
24
+ gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
25
+ gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
26
+ gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
27
+ # s3 check
28
+ gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
29
+
30
+ gem 'webpacker', '~> 4.0.7' # REQUIRED
@@ -0,0 +1,29 @@
1
+ # Gemfile for health_test testing
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
6
+
7
+ gem 'rails', '~> 6.1.0'
8
+ gem 'rake', '>= 0.8.7'
9
+
10
+ group :development, :test do
11
+ if defined?(JRUBY_VERSION)
12
+ gem 'jruby-openssl'
13
+ gem 'activerecord-jdbcsqlite3-adapter'
14
+ else
15
+ gem 'sqlite3', "~> 1.3.7"
16
+ end
17
+ gem 'shoulda'
18
+ end
19
+
20
+ # redis based checks
21
+ gem 'sidekiq', require: !ENV['SIDEKIQ'].nil? # REQUIRED
22
+ gem 'redis', require: !ENV['REDIS_URL'].nil? # REQUIRED
23
+ gem 'resque', require: !ENV['RESQUE'].nil? # REQUIRED
24
+ # s3 check
25
+ gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
26
+
27
+ gem 'webpacker', '~> 4.0.7' # REQUIRED
28
+ gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
29
+ gem 'webrick' # REQUIRED for ruby 3.0
@@ -0,0 +1,30 @@
1
+ # Gemfile for health_test testing
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
6
+
7
+ gem 'rails', '~> 6.2.0'
8
+ gem 'rake', '>= 0.8.7'
9
+
10
+ group :development, :test do
11
+ if defined?(JRUBY_VERSION)
12
+ gem 'jruby-openssl'
13
+ gem 'activerecord-jdbcsqlite3-adapter'
14
+ else
15
+ gem 'sqlite3', "~> 1.3.7"
16
+ end
17
+ gem 'shoulda'
18
+ end
19
+
20
+ # redis based checks
21
+ gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
22
+ gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
23
+ gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
24
+ gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
25
+ # s3 check
26
+ gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
27
+
28
+ gem 'webpacker', '~> 4.0.7' # REQUIRED
29
+ gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
30
+ gem 'webrick' # REQUIRED for ruby 3.0
@@ -18,15 +18,20 @@ group :development, :test do
18
18
  gem 'sqlite3'
19
19
  end
20
20
  gem 'shoulda'
21
-
22
- # redis based checks
23
- gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
24
- gem 'redis', :require => !ENV['REDIS_URL'].nil?
25
- gem 'resque', :require => !ENV['RESQUE'].nil?
26
- # s3 check
27
- gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
28
21
  end
29
22
 
23
+ # redis based checks
24
+ gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
25
+ gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
26
+ gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
27
+ gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
28
+ # s3 check
29
+ gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
30
+
30
31
  # Initial Gemfile has therubyracer commented out
31
- gem 'therubyrhino', :platform => :jruby # REQUIRED
32
- gem 'therubyracer', :platform => :ruby # REQUIRED
32
+ gem 'therubyrhino', platform: :jruby # REQUIRED
33
+ gem 'therubyracer', platform: :ruby # REQUIRED
34
+
35
+ gem 'webpacker', '~> 4.0.7' # REQUIRED
36
+ gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
37
+ gem 'webrick' # REQUIRED for ruby 3.0
data/test/setup_railsapp CHANGED
@@ -2,15 +2,27 @@
2
2
 
3
3
  route_prefix=medical_check
4
4
 
5
- err_report() {
6
- echo "$0: Error on line $1 - aborted"
7
- exit 1
5
+ # Any failure causes exit
6
+ set -eE -o functrace
7
+
8
+ report_failure() {
9
+ local lineno=$2
10
+ local fn=$3
11
+ local exitstatus=$4
12
+ local msg=$5
13
+ local lineno_fns=${1% 0}
14
+ if [[ $lineno_fns != "0" ]] ; then
15
+ lineno="${lineno} ${lineno_fns}"
16
+ fi
17
+ if [[ $exitstatus == 0 ]] ; then
18
+ echo "${BASH_SOURCE[1]}: Finished!"
19
+ else
20
+ echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
21
+ fi
8
22
  }
9
23
 
10
- trap 'err_report $LINENO' ERR
24
+ trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
11
25
 
12
- # Any failure causes exit
13
- set -e
14
26
 
15
27
  case "$1" in
16
28
  [0-9]*)
@@ -54,14 +66,21 @@ mkdir -p tmp/gems
54
66
  if $rbenv_which bundle ; then
55
67
  echo Bundler is installed
56
68
  else
57
- gem install bundler
69
+ gem install bundler ${BUNDLER_VERSION:+-v ${BUNDLER_VERSION}}
58
70
  $rehash
59
71
  fi
60
72
 
61
73
  echo "Running bundle with BUNDLE_GEMFILE=$BUNDLE_GEMFILE ..."
62
- if ! bundle install ; then
74
+ if ! smarter_bundle ; then
63
75
  echo "Test aborted (missing required gems)"
64
76
  exit 2
77
+ elif [ ! -s $BUNDLE_GEMFILE.lock ] ; then
78
+ echo "Error: smarter_bundler return OK status BUT lock file ($BUNDLE_GEMFILE.lock) is missing!"
79
+ exit 3
80
+ else
81
+ echo bundle passed - lock file contains:
82
+ cat $BUNDLE_GEMFILE.lock
83
+ echo
65
84
  fi
66
85
  $rehash
67
86
 
@@ -69,9 +88,9 @@ rails="$base_dir/test/bin/rails"
69
88
  rake="$base_dir/test/bin/rake"
70
89
 
71
90
  echo Checking $rails is present ...
72
- [ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
73
- [ -f $rails ] || bundle binstubs railties || echo '(ignored bundle exit status)'
74
- [ -f $rails ] || bundle binstubs rails || echo '(ignored bundle exit status)'
91
+ [ -f $rails -a -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
92
+ [ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs railties || echo '(ignored bundle exit status)'
93
+ [ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rails || echo '(ignored bundle exit status)'
75
94
  if [ ! -f $rails ]; then
76
95
  echo "Test aborted (unable to create $rails)"
77
96
  exit 2
@@ -79,7 +98,7 @@ fi
79
98
 
80
99
  if [ ! -f $rake ]; then
81
100
  echo "Running bundle binstubs rake ..."
82
- if ! bundle binstubs rake || [ ! -f $rake ]; then
101
+ if ! bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rake || [ ! -f $rake ]; then
83
102
  echo "Test aborted (unable to create $rake)"
84
103
  exit 2
85
104
  fi
@@ -124,16 +143,25 @@ esac
124
143
 
125
144
  echo "Creating $actual_rails_version app in $tmp_dir/railsapp using adapter $db"
126
145
  case "$actual_rails_version" in
127
- *' '[12].*)
128
- $rails railsapp -d $db
129
- ;;
130
146
  *' '[345].*)
147
+ args="--skip-bundle -d $db"
131
148
  case "$BUNDLE_GEMFILE" in
132
149
  *rails_edge.gemfile)
133
- $rails new railsapp -d $db --edge
150
+ $rails new railsapp $args --edge
134
151
  ;;
135
152
  *)
136
- $rails new railsapp -d $db
153
+ $rails new railsapp $args
154
+ ;;
155
+ esac
156
+ ;;
157
+ *' '[6].*)
158
+ args="--skip-bundle -d $db --skip-git --skip-bootsnap"
159
+ case "$BUNDLE_GEMFILE" in
160
+ *rails_edge.gemfile)
161
+ $rails new railsapp $args --edge
162
+ ;;
163
+ *)
164
+ $rails new railsapp $args
137
165
  ;;
138
166
  esac
139
167
  ;;
@@ -155,25 +183,47 @@ echo "Configuring mailer to point to fake_smtp_server port 3555"
155
183
  cat >> config/environment.rb <<'!EOF!'
156
184
 
157
185
  ActionMailer::Base.delivery_method = :smtp
158
- ActionMailer::Base.smtp_settings = { :address => "localhost", :port => 3555 }
186
+ ActionMailer::Base.smtp_settings = { address: "localhost", port: 3555 }
159
187
 
160
188
  !EOF!
161
189
 
162
190
  echo Adding an initializer for health_check gem ...
163
191
  mkdir -p config/initializers
164
192
  tee config/initializers/health_check.rb <<!
165
- HealthCheck.setup do |config|
166
- config.success = "$success"
167
- config.smtp_timeout = 60.0
168
- config.http_status_for_error_text = 550
169
- config.http_status_for_error_object = 555
170
- config.uri = '$route_prefix'
171
- config.origin_ip_whitelist = ENV['IP_WHITELIST'].split(',') unless ENV['IP_WHITELIST'].blank?
172
- config.basic_auth_username = ENV['AUTH_USER'] unless ENV['AUTH_USER'].blank?
173
- config.basic_auth_password = ENV['AUTH_PASSWORD'] unless ENV['AUTH_PASSWORD'].blank?
174
-
175
- config.add_custom_check do
176
- File.exists?("$custom_file") ? '' : '$custom_file is missing!'
193
+ require 'fileutils'
194
+
195
+ if defined? HealthCheck
196
+ HealthCheck.setup do |config|
197
+ config.success = "$success"
198
+ config.smtp_timeout = 60.0
199
+ config.http_status_for_error_text = 550
200
+ config.http_status_for_error_object = 555
201
+ config.uri = '$route_prefix'
202
+ config.origin_ip_whitelist = ENV['IP_WHITELIST'].split(',') unless ENV['IP_WHITELIST'].blank?
203
+ config.basic_auth_username = ENV['AUTH_USER'] unless ENV['AUTH_USER'].blank?
204
+ config.basic_auth_password = ENV['AUTH_PASSWORD'] unless ENV['AUTH_PASSWORD'].blank?
205
+
206
+ config.add_custom_check do
207
+ File.exists?("$custom_file") ? '' : '$custom_file is missing!'
208
+ end
209
+
210
+ config.add_custom_check('pass') do
211
+ ''
212
+ end
213
+
214
+ config.on_failure do |checks, msg|
215
+ File.open('tmp/health_check_failure.txt', 'w') do |f|
216
+ f.puts "FAILED: #{checks}, MESSAGE: #{msg}"
217
+ end
218
+ end
219
+
220
+ config.on_success do |checks|
221
+ File.open('tmp/health_check_success.txt', 'w') do |f|
222
+ f.puts "PASSED: #{checks}"
223
+ end
224
+ end
225
+
226
+ config.include_error_in_response_body = ENV['HIDE_ERROR_RESPONSE'].to_s !~ /^[1tTyY]/
177
227
  end
178
228
  end
179
229
  !
@@ -183,71 +233,89 @@ INITIAL_BUNDLE_GEMFILE="$BUNDLE_GEMFILE"
183
233
  echo Unsetting BUNDLE_GEMFILE '(so Gemfile for rails application will be used)'
184
234
  unset BUNDLE_GEMFILE
185
235
 
186
- if [ -s Gemfile ]
236
+ if [ ! -s Gemfile ]
187
237
  then
188
- echo Adding health_check as gem to Gemfile...
189
- echo "gem 'health_check', :path => '$base_dir'" >> Gemfile
238
+ echo Missing Gemfile!
239
+ exit 2
240
+ fi
241
+ echo Adding health_check as gem to Gemfile...
242
+ echo "gem 'health_check', path: '$base_dir'" >> Gemfile
190
243
 
191
- case "$RAILS_SERVER" in
192
- webrick|'')
193
- echo "Using default webrick server"
194
- ;;
195
- *)
196
- echo "Adding $RAILS_SERVER gem to Gemfile (for use as server)"
197
- echo "gem '$RAILS_SERVER'" >> Gemfile
198
- ;;
199
- esac
200
- egrep REQUIRED < ${INITIAL_BUNDLE_GEMFILE} >> Gemfile || echo No required gems found...
201
- echo
202
- echo ================= Gemfile ===================
203
- cat Gemfile
204
- echo
205
- echo running bundle install
206
- bundle install
207
- $rehash
208
- echo "Using binstubs in $railsapp/bin for rails and rake commands"
209
- rails="$railsapp/bin/rails"
210
- rake="$railsapp/bin/rake"
211
-
212
- echo Checking $rails is present ...
213
- [ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
214
- [ -f $rails ] || bundle binstubs railties || echo '(ignored bundle exit status)'
215
- [ -f $rails ] || bundle binstubs rails || echo '(ignored bundle exit status)'
216
- if [ ! -f $rails ]; then
217
- echo "Test aborted (unable to create $rails)"
218
- exit 2
219
- fi
244
+ case "$RAILS_SERVER" in
245
+ webrick|'')
246
+ echo "Using default webrick server"
247
+ ;;
248
+ *)
249
+ echo "Adding $RAILS_SERVER gem to Gemfile (for use as server)"
250
+ echo "gem '$RAILS_SERVER'" >> Gemfile
251
+ ;;
252
+ esac
253
+ TAB=$'\t'
254
+ QUOTES='"'"'"
255
+ case "$actual_rails_version" in
256
+ *' '5.0*)
257
+ if egrep -i 'gem.*sqlite3' Gemfile ; then
258
+ # Can't do this as a require as we may go back to testing JRuby
259
+ echo Force sqlite to 1.3.13+ version for Rails 5.0 ...
260
+ gem=sqlite3
261
+ sed -i.bak -e "s/^\([ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]${gem}[${QUOTES}]\)\(.*\)$/\1, '~> 1.3.13' # overriden: \2/" Gemfile
262
+ fi
263
+ ;;
264
+ esac
265
+ if egrep -q REQUIRED ${INITIAL_BUNDLE_GEMFILE} ; then
266
+ sed -n "s/^[ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]\([^${QUOTES}]*\)[${QUOTES}].*REQUIRED.*/\1/p" ${INITIAL_BUNDLE_GEMFILE} | while read gem
267
+ do
268
+ echo "Commenting out gem '$gem' line in Gemfile"
269
+ sed -i.bak -e "s/^\([ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]${gem}[${QUOTES}].*\)$/# overriden by REQUIRED below: \1/" Gemfile
270
+ done
271
+ echo Adding Required gems
272
+ egrep REQUIRED ${INITIAL_BUNDLE_GEMFILE} | tee -a Gemfile
273
+ else
274
+ echo No required gems to be added to Gemfile
275
+ fi
220
276
 
221
- echo Checking $rake is present ...
222
- [ -f $rake ] || bundle binstubs rake || echo '(ignored bundle exit status)'
223
- if [ ! -f $rake ]; then
224
- echo "Test aborted (unable to create $rake)"
225
- exit 2
226
- fi
277
+ echo
278
+ echo ================= $PWD/Gemfile ===================
279
+ cat Gemfile
280
+ echo
281
+ echo ==================================================
282
+ echo running smarter_bundle install
283
+ smarter_bundle install
284
+ $rehash
227
285
 
228
- $rehash
229
- # Fix for rvm, otherwise bundle run from rails create fails
230
- export PATH="`pwd`/bin:$PATH"
231
- echo ================= Gemfile.lock ===================
232
- cat Gemfile.lock
233
- echo
234
- else
235
- dest=$railsapp/vendor/plugins/health_check
236
- echo Installing health_check as plugin in $dest ...
237
- mkdir -p $dest
238
- (
239
- cd $base_dir
286
+ if egrep webpacker Gemfile && [ ! -f config/webpacker.yml ] ; then
287
+ echo completing setup by running rails webpacker:install ...
288
+ $rails webpacker:install
289
+ fi
290
+
291
+ echo "Using binstubs in $railsapp/bin for rails and rake commands"
292
+ rails="$railsapp/bin/rails"
293
+ rake="$railsapp/bin/rake"
240
294
 
241
- git ls-files | cpio -pdl $dest
242
-
243
- cd $dest
295
+ echo Checking $rails is present ...
296
+ [ -f $rails -a -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
297
+ [ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs railties || echo '(ignored bundle exit status)'
298
+ [ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rails || echo '(ignored bundle exit status)'
299
+ if [ ! -f $rails ]; then
300
+ echo "Test aborted (unable to create $rails)"
301
+ exit 2
302
+ fi
244
303
 
245
- echo Files installed as plugin:
246
- find . -type f
247
- echo
248
- )
304
+ echo Checking $rake is present ...
305
+ [ -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rake || echo '(ignored bundle exit status)'
306
+ if [ ! -f $rake ]; then
307
+ echo "Test aborted (unable to create $rake)"
308
+ exit 2
249
309
  fi
250
310
 
311
+ $rehash
312
+ # Fix for rvm, otherwise bundle run from rails create fails
313
+ export PATH="`pwd`/bin:$PATH"
314
+ echo ================= $PWD/Gemfile.lock ===================
315
+ cat Gemfile.lock
316
+ echo ==================================================
317
+ echo
318
+
251
319
  for e in test ${RAILS_ENV2:-production}
252
320
  do
253
321
  if [ -f config/environments/$e.rb ]; then
@@ -259,11 +327,22 @@ do
259
327
  echo
260
328
  fi
261
329
  done
262
- echo "============== config/environment.rb ============="
330
+
331
+ if egrep -q 'bootsnap.setup' config/boot.rb ; then
332
+ echo Commenting out bootsnap from config/boot.rb
333
+ sed -i.bak -e 's/^\(.*bootsnap.setup\)/# \1/' config/boot.rb
334
+ echo "============== $PWD/config/boot.rb ============="
335
+ cat config/boot.rb
336
+ echo ==================================================
337
+ fi
338
+ rm -rf tmp/cache/bootsnap*
339
+ echo
340
+
341
+ echo "============== $PWD/config/environment.rb ============="
263
342
  cat config/environment.rb
264
343
  echo
265
344
 
266
- echo ========================
345
+ echo =========================================================
267
346
  case $db in
268
347
  jdbcsqlite3)
269
348
  for e in test ${RAILS_ENV2:-production}
@@ -354,11 +433,11 @@ cat > app/controllers/example_controller.rb <<'EOF'
354
433
  class ExampleController < ApplicationController
355
434
 
356
435
  def index
357
- render :text => 'example page'
436
+ render plain: 'example page'
358
437
  end
359
438
 
360
439
  def catchall
361
- render :text => 'catch all route'
440
+ render plain: 'catch all route'
362
441
  end
363
442
 
364
443
  end
@@ -380,7 +459,7 @@ case "$MIDDLEWARE" in
380
459
 
381
460
  echo " # -----------------------------------------"
382
461
  echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
383
- echo " config.middleware.insert_after 'Rails::Rack::Logger', HealthCheck::MiddlewareHealthcheck"
462
+ echo " config.middleware.insert_after Rails::Rack::Logger, HealthCheck::MiddlewareHealthcheck"
384
463
  echo " # END OF SECTION FOR TESTING HEALTH_CHECK"
385
464
  echo " # ---------------------------------------"
386
465
  ruby -n -e 'print if /^ *end/..9999' config/application.rb-old | tee /tmp/t$$
@@ -392,7 +471,7 @@ case "$MIDDLEWARE" in
392
471
 
393
472
  #echo =============== config/application.rb-old ========================
394
473
  #cat config/application.rb-old
395
- echo =============== config/application.rb ========================
474
+ echo =============== $PWD/config/application.rb ========================
396
475
  cat config/application.rb
397
476
  else
398
477
  echo FAILED: NO config/application.rb file!!
@@ -416,11 +495,12 @@ if [ -s config/routes.rb ]; then
416
495
  # rails 3.0+
417
496
  echo " # -----------------------------------------"
418
497
  echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
419
- echo " get 'example(/:action(/:id))(.:format)' => 'example'"
498
+ echo " get 'example/catchall(.:format)', controller: :example, action: :catchall"
499
+ echo " get 'example(.:format)', controller: :example, action: :index"
420
500
  echo " if File.exists?('$catchall_file')"
421
501
  echo " health_check_routes"
422
502
  echo " # CATCH ALL ROUTE"
423
- echo " get '*path', :to => 'example#catchall'"
503
+ echo " get '*path', controller: :example, action: :catchall"
424
504
  echo " end"
425
505
  echo " # END OF SECTION FOR TESTING HEALTH_CHECK"
426
506
  echo " # ---------------------------------------"