forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BACKTRACE env variable to turn off backtrace for normal running, …
…not just tests
- Loading branch information
1 parent
0d940e3
commit 957a3e5
Showing
5 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
require "isolation/abstract_unit" | ||
require "rack/test" | ||
require "env_helpers" | ||
|
||
module ApplicationTests | ||
class RoutingTest < ActiveSupport::TestCase | ||
include ActiveSupport::Testing::Isolation | ||
include Rack::Test::Methods | ||
include EnvHelpers | ||
|
||
def teardown | ||
teardown_app | ||
end | ||
|
||
test "backtrace is cleaned" do | ||
setup_app | ||
|
||
app("development") | ||
get "/" | ||
assert_includes last_response.body, "app/app/controllers/foo_controller.rb:4:in `index'" | ||
assert_not_includes last_response.body, "rails/railties/test/env_helpers.rb" | ||
end | ||
|
||
test "backtrace is not cleaned" do | ||
switch_env("BACKTRACE", "1") do | ||
setup_app | ||
|
||
app("development") | ||
get "/" | ||
assert_includes last_response.body, "app/app/controllers/foo_controller.rb:4:in `index'" | ||
assert_includes last_response.body, "rails/railties/test/env_helpers.rb" | ||
end | ||
end | ||
|
||
private | ||
def setup_app | ||
build_app | ||
|
||
controller :foo, <<-RUBY | ||
class FooController < ApplicationController | ||
def index | ||
begin | ||
raise "ERROR" | ||
rescue StandardError => e | ||
render plain: e.backtrace.join("\n") | ||
end | ||
end | ||
end | ||
RUBY | ||
|
||
app_file "config/routes.rb", <<-RUBY | ||
Rails.application.routes.draw do | ||
root to: "foo#index" | ||
end | ||
RUBY | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters