提交 f39ab9f3 编写于 作者: A Andrew White

Merge pull request #21849 from yui-knk/refactor_regexp_to_string

Change `Journey::Route#verb` to return string instead of regexp.
......@@ -163,7 +163,7 @@ def requires_matching_verb?
end
def verb
%r[^#{verbs.join('|')}$]
verbs.join('|')
end
private
......
......@@ -16,10 +16,6 @@ def rack_app
app.app
end
def verb
super.source.gsub(/[$^]/, '')
end
def path
super.spec.to_s
end
......
......@@ -82,7 +82,7 @@ def test_random_keys
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 @@ def test_via_scope
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
......
......@@ -77,6 +77,17 @@ def test_cart_inspect
], 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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册