Skip to content

Instantly share code, notes, and snippets.

@JoeDupuis
Last active May 9, 2023 17:30
Show Gist options
  • Save JoeDupuis/e0f18020c85a05d5188ee35485685387 to your computer and use it in GitHub Desktop.
Save JoeDupuis/e0f18020c85a05d5188ee35485685387 to your computer and use it in GitHub Desktop.
rails_48013_repro
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
gem "rack", "~> 2.0"
end
require "minitest/autorun"
require "rack/test"
require "action_controller/railtie"
class App < Rails::Application
config.root = __dir__
secrets.secret_key_base = "secret_key_base"
config.hosts << "example.org"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get 'cause_the_failure_if_first', to: 'test#index'
get 'expected_route', to: 'test#index'
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def index
render plain: url_for()
end
end
class UrlForTest < Minitest::Test
include Rack::Test::Methods
include Rails.application.routes.url_helpers
def test_expected_route
get '/expected_route'
assert_equal "http://example.org/expected_route", last_response.body.force_encoding("utf-8")
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