aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-04-03 16:53:51 -0400
committerGitHub <noreply@github.com>2019-04-03 16:53:51 -0400
commit9d02b1bd58a20f34d36c461a0b88bfe590655b54 (patch)
tree45e6f472e112613b245b621933f5ae989c40d888 /actionpack
parent8113c8e1238939c8c68c2598b0a78a5b2171943d (diff)
parented7234860b061b7b82672e6ba51c682254cd7eb7 (diff)
downloadrails-9d02b1bd58a20f34d36c461a0b88bfe590655b54.tar.gz
rails-9d02b1bd58a20f34d36c461a0b88bfe590655b54.tar.bz2
rails-9d02b1bd58a20f34d36c461a0b88bfe590655b54.zip
Merge pull request #35842 from Shopify/deduplicate-routing-strings
Deduplicate strings held by the router
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/renderer.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb10
-rw-r--r--actionpack/test/dispatch/routing_test.rb4
3 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb
index 8c16308ce7..dadf6d3445 100644
--- a/actionpack/lib/action_controller/renderer.rb
+++ b/actionpack/lib/action_controller/renderer.rb
@@ -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)
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 74596fa1f0..f29f66990d 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -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.
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 11772a36a3..362488d585 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -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