Skip to content

Instantly share code, notes, and snippets.

@hogelog
Created May 14, 2018 13:27
Show Gist options
  • Save hogelog/ac69d9c94df988a32fdfcf41b14cc1c1 to your computer and use it in GitHub Desktop.
Save hogelog/ac69d9c94df988a32fdfcf41b14cc1c1 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
gem "rails", "5.2.0"
end
require "rack/test"
require "action_controller/railtie"
class TestApp < Rails::Application
config.root = __dir__
config.session_store :cookie_store, key: "cookie_store_key"
secrets.secret_key_base = "secret_key_base"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get "/:keyword" => "test#show", as: :test, keyword: %r([^/]*)
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def show
render plain: test_path(params[:keyword])
end
end
require "minitest/autorun"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_returns_success
get "/foo%2Fbar"
assert last_response.ok?
assert_equal "/foo%2Fbar", last_response.body
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