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

Change Journey::Route#verb to return string instead of regexp.

By [this commit](0b476de445)
`Journey::Route#verb` need not to return verb as regexp.
The returned value is used by inspector, so change it to be a string.

Add inspect_with_multiple_verbs test case to keep the behavior of
inspector correctly.
This commit is contained in:
yui-knk 2015-10-03 18:28:29 +09:00
parent 37423e4ff8
commit 218336fa54
4 changed files with 14 additions and 7 deletions

View file

@ -163,7 +163,7 @@ module ActionDispatch
end
def verb
%r[^#{verbs.join('|')}$]
verbs.join('|')
end
private

View file

@ -16,10 +16,6 @@ module ActionDispatch
app.app
end
def verb
super.source.gsub(/[$^]/, '')
end
def path
super.spec.to_s
end

View file

@ -82,7 +82,7 @@ module ActionDispatch
end
assert_equal({:omg=>:awesome, :controller=>"posts", :action=>"index"},
fakeset.defaults.first)
assert_equal(/^GET$/, fakeset.routes.first.verb)
assert_equal("GET", fakeset.routes.first.verb)
end
def test_mapping_requirements
@ -99,7 +99,7 @@ module ActionDispatch
mapper.scope(via: :put) do
mapper.match '/', :to => 'posts#index', :as => :main
end
assert_equal(/^PUT$/, fakeset.routes.first.verb)
assert_equal("PUT", fakeset.routes.first.verb)
end
def test_map_slash

View file

@ -77,6 +77,17 @@ module ActionDispatch
], output
end
def test_articles_inspect_with_multiple_verbs
output = draw do
match 'articles/:id', to: 'articles#update', via: [:put, :patch]
end
assert_equal [
"Prefix Verb URI Pattern Controller#Action",
" PUT|PATCH /articles/:id(.:format) articles#update"
], output
end
def test_inspect_shows_custom_assets
output = draw do
get '/custom/assets', :to => 'custom_assets#show'