Skip to content

Instantly share code, notes, and snippets.

@hmarr
Created March 20, 2015 16:28
Show Gist options
  • Save hmarr/054ee23e5a66afae2f7b to your computer and use it in GitHub Desktop.
Save hmarr/054ee23e5a66afae2f7b to your computer and use it in GitHub Desktop.
$ echo "source 'https://rubygems.org'\ngem 'rails', '4.2.0'" > Gemfile && bundle install
[truncated]
Using rails 4.2.0
Your bundle is complete!
It was installed into ./.bundle
$ bundle exec ruby routing_issue.rb
Run options: --seed 9548
# Running:
....
Finished in 0.066622s, 60.0402 runs/s, 60.0402 assertions/s.
4 runs, 4 assertions, 0 failures, 0 errors, 0 skips
$ echo "source 'https://rubygems.org'\ngem 'rails', '4.2.1'" > Gemfile && bundle install
[truncated]
Using rails 4.2.1 (was 4.2.0)
Your bundle is complete!
It was installed into ./.bundle
$ bundle exec ruby routing_issue.rb
Run options: --seed 9252
# Running:
..F.
Finished in 0.111500s, 35.8744 runs/s, 35.8744 assertions/s.
1) Failure:
BugTest#test_head_health_check_returns_503 [routing_issue.rb:56]:
Expected: 404
Actual: 503
4 runs, 4 assertions, 1 failures, 0 errors, 0 skips
require 'bundler'
Bundler.setup(:default)
require 'rails'
require 'action_controller/railtie'
class HealthCheck
def call(env)
[503, {}, 'not available']
end
end
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
secrets.secret_token = 'secret_token'
secrets.secret_key_base = 'secret_key_base'
config.logger = Logger.new(File.open('/dev/null', 'a'))
Rails.logger = config.logger
routes.draw do
get '/test' => 'test#index'
mount HealthCheck.new, at: '/health_check'
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def index
render json: {}, status: 200
end
end
require 'minitest/autorun'
require 'rack/test'
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_get_test_returns_success
get '/test'
assert last_response.ok?
end
def test_head_test_returns_success
head '/test'
assert last_response.ok?
end
def test_get_health_check_returns_503
get '/health_check'
assert_equal last_response.status, 503
end
def test_head_health_check_returns_503
head '/health_check'
assert_equal last_response.status, 503
end
private
def app
Rails.application
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment