Merge pull request #52303 from Shopify/routing_source_locations_in_command
Only enable routing source locations when using routes command
This commit is contained in:
commit
099776069c
@ -68,8 +68,6 @@ class Railtie < Rails::Railtie # :nodoc:
|
|||||||
config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
|
config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
|
||||||
ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
|
ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
|
||||||
|
|
||||||
ActionDispatch::Routing::Mapper.route_source_locations = Rails.env.development?
|
|
||||||
|
|
||||||
ActionDispatch::Http::Cache::Request.strict_freshness = app.config.action_dispatch.strict_freshness
|
ActionDispatch::Http::Cache::Request.strict_freshness = app.config.action_dispatch.strict_freshness
|
||||||
ActionDispatch.test_app = app
|
ActionDispatch.test_app = app
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
require "active_support/core_ext/enumerable"
|
require "active_support/core_ext/enumerable"
|
||||||
require "active_support/core_ext/array/extract_options"
|
require "active_support/core_ext/array/extract_options"
|
||||||
require "active_support/core_ext/regexp"
|
require "active_support/core_ext/regexp"
|
||||||
|
require "action_dispatch/routing"
|
||||||
require "action_dispatch/routing/redirection"
|
require "action_dispatch/routing/redirection"
|
||||||
require "action_dispatch/routing/endpoint"
|
require "action_dispatch/routing/endpoint"
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
* Enable tracking route source locations only when using routes command. Previously,
|
||||||
|
it was enabled in development mode, but is only needed for `bin/rails routes -E`.
|
||||||
|
|
||||||
|
*Gannon McGibbon*
|
||||||
|
|
||||||
* Deprecate `bin/rake stats` in favor of `bin/rails stats`.
|
* Deprecate `bin/rake stats` in favor of `bin/rails stats`.
|
||||||
|
|
||||||
*Juan Vásquez*
|
*Juan Vásquez*
|
||||||
|
@ -22,6 +22,8 @@ def invoke_command(*)
|
|||||||
|
|
||||||
desc "routes", "List all the defined routes"
|
desc "routes", "List all the defined routes"
|
||||||
def perform(*)
|
def perform(*)
|
||||||
|
require "action_dispatch/routing/mapper"
|
||||||
|
ActionDispatch::Routing::Mapper.route_source_locations = true
|
||||||
boot_application!
|
boot_application!
|
||||||
require "action_dispatch/routing/inspector"
|
require "action_dispatch/routing/inspector"
|
||||||
|
|
||||||
|
@ -403,6 +403,12 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
|
|||||||
assert_includes(output, "No unused routes found.")
|
assert_includes(output, "No unused routes found.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "route source locations aren't included when booted normally" do
|
||||||
|
output = rails "runner", "print !!ActionDispatch::Routing::Mapper.route_source_locations"
|
||||||
|
|
||||||
|
assert_equal("false", output)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def run_routes_command(args = [])
|
def run_routes_command(args = [])
|
||||||
rails "routes", args
|
rails "routes", args
|
||||||
|
Loading…
Reference in New Issue
Block a user