Skip to content

Instantly share code, notes, and snippets.

@abrom
Created May 19, 2020 03:02
Show Gist options
  • Save abrom/e939a92604f2e398c10bb012e8e11c8d to your computer and use it in GitHub Desktop.
Save abrom/e939a92604f2e398c10bb012e8e11c8d to your computer and use it in GitHub Desktop.
# 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: 'v6.0.2.2'
gem "rails", github: "rails/rails", branch: 'v6.0.3.1'
end
require "action_controller/railtie"
class TestApp < Rails::Application
config.root = __dir__
config.hosts << "example.org"
secrets.secret_key_base = "secret_key_base"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
with_options only: %i[show], controller: :test do
resource :foo, baz: '123' do
get :qux
end
resource :bar, baz: '456' do
get :qux
end
end
scope :test2 do
with_options only: %i[show], controller: :test2 do
resource :foo, baz: '123' do
get :qux
end
resource :bar, baz: '456' do
get :qux
end
end
end
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def show
render plain: "Home"
end
end
class Test2Controller < TestController
end
require "minitest/autorun"
require "rack/test"
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_unscoped_returns_success
get "/bar"
assert last_response.ok?
end
def test_scoped_returns_success
get "/test2/bar"
assert last_response.ok?
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