1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #35842 from Shopify/deduplicate-routing-strings

Deduplicate strings held by the router
This commit is contained in:
Rafael França 2019-04-03 16:53:51 -04:00 committed by GitHub
commit 9d02b1bd58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -116,7 +116,7 @@ module ActionController
RACK_VALUE_TRANSLATION = {
https: ->(v) { v ? "on" : "off" },
method: ->(v) { v.upcase },
method: ->(v) { -v.upcase },
}
def rack_key_for(key)

View file

@ -115,9 +115,9 @@ module ActionDispatch
@defaults = defaults
@set = set
@to = to
@default_controller = controller
@default_action = default_action
@to = intern(to)
@default_controller = intern(controller)
@default_action = intern(default_action)
@ast = ast
@anchor = anchor
@via = via
@ -222,6 +222,10 @@ module ActionDispatch
private :build_path
private
def intern(object)
object.is_a?(String) ? -object : object
end
def add_wildcard_options(options, formatted, path_ast)
# Add a constraint for wildcard route to make it non-greedy and match the
# optional format part of the route by default.

View file

@ -3379,13 +3379,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_match(/:param option can't contain colon/, ex.message)
end
def test_action_from_path_is_not_frozen
def test_action_from_path_is_frozen
draw do
get "search" => "search"
end
get "/search"
assert_not_predicate @request.params[:action], :frozen?
assert_predicate @request.params[:action], :frozen?
end
def test_multiple_positional_args_with_the_same_name