aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-11-09 05:10:39 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2010-11-09 05:24:10 +0000
commitef46b9f21a275249d1b0cf9926ffb879b0ae2c44 (patch)
treeaa2f8a092c0718ac66778de55f63470465847736
parent4e0477c9b75683372f662a614ae91b158120ebe8 (diff)
downloadrails-ef46b9f21a275249d1b0cf9926ffb879b0ae2c44.tar.gz
rails-ef46b9f21a275249d1b0cf9926ffb879b0ae2c44.tar.bz2
rails-ef46b9f21a275249d1b0cf9926ffb879b0ae2c44.zip
Strip regexp anchors from rake routes output [#5934 state:resolved]
-rw-r--r--actionpack/lib/action_dispatch/routing/route.rb3
-rw-r--r--railties/test/application/rake_test.rb9
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route.rb b/actionpack/lib/action_dispatch/routing/route.rb
index f91a48e16c..08a8408f25 100644
--- a/actionpack/lib/action_dispatch/routing/route.rb
+++ b/actionpack/lib/action_dispatch/routing/route.rb
@@ -30,7 +30,8 @@ module ActionDispatch
if method = conditions[:request_method]
case method
when Regexp
- method.source.upcase
+ source = method.source.upcase
+ source =~ /\A\^[-A-Z|]+\$\Z/ ? source[1..-2] : source
else
method.to_s.upcase
end
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index 8e527236ea..719550f9d9 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -38,5 +38,14 @@ module ApplicationTests
assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0",
Dir.chdir(app_path){ `rake stats` }
end
+
+ def test_rake_routes_output_strips_anchors_from_http_verbs
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ get '/cart', :to => 'cart#show'
+ end
+ RUBY
+ assert_match 'cart GET /cart(.:format)', Dir.chdir(app_path){ `rake routes` }
+ end
end
end