Skip to content

Instantly share code, notes, and snippets.

@ghiculescu
Created July 6, 2022 19:55
Show Gist options
  • Save ghiculescu/1d5510e5e4559754a7470266cd2fce63 to your computer and use it in GitHub Desktop.
Save ghiculescu/1d5510e5e4559754a7470266cd2fce63 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: "main"
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
get "/" => "test#index"
end
end
class A < ActionController::Base
include Rails.application.routes.url_helpers
before_action :do_the_before_action
def index
render(plain: @to_render || "no before action")
end
private
def do_the_before_action
@to_render = "before action"
end
end
class B < A
skip_before_action :do_the_before_action
end
class TestController < B
skip_before_action :do_the_before_action
end
require "minitest/autorun"
require "rack/test"
class BugTest < Minitest::Test
include Rack::Test::Methods
def test_returns_success
get "/"
assert_equal "no before action", 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