Skip to content

Instantly share code, notes, and snippets.

@nicohvi
Created February 4, 2020 12:18
Show Gist options
  • Save nicohvi/96868f0abc3f3d5c29f76a37665a5be6 to your computer and use it in GitHub Desktop.
Save nicohvi/96868f0abc3f3d5c29f76a37665a5be6 to your computer and use it in GitHub Desktop.
begin
require 'bundler/inline'
rescue LoadError => e
$sdterr.puts "Bundler version 1.10 or later is required"
raise
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '6.0.1'
end
require 'rack/test'
require 'action_controller/railtie'
require 'minitest/autorun'
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
secrets.secret_token = 'secret_token'
secrets.secret_key_base = 'secret_key_base'
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
root to: 'test#index'
end
end
class TestController < ActionController::Base
def default_url_options
{
host: 'www.example.com'
}
end
def index
render plain: 'success'
end
end
# Comment in these lines to make tests pass.
# Rails.application.routes.default_url_options = {
# host: 'www.example.com'
# }
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_if_host_is_read
assert_equal 'http://www.example.com/', Rails.application.routes.url_helpers.root_url
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