Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bf191318
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf191318
编写于
1月 20, 2014
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tidy up tests and CHANGELOG for #12598
上级
f9f32e04
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
7 deletion
+37
-7
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+13
-2
actionpack/test/dispatch/routing/inspector_test.rb
actionpack/test/dispatch/routing/inspector_test.rb
+14
-3
actionpack/test/dispatch/routing/route_set_test.rb
actionpack/test/dispatch/routing/route_set_test.rb
+0
-2
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+10
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
bf191318
*
Add ability to set a prefix name for routes which have hyphen(s).
*
Automatically convert dashes to underscores for shorthand routes, e.g:
get '/our-work/latest'
When running `rake routes` you will get the following output:
Prefix Verb URI Pattern Controller#Action
our_work_latest GET /our-work/latest(.:format) our_work#latest
*Mikko Johansson*
*
Automatically convert dashes to underscores for url helpers, e.g:
get '/contact-us' => 'pages#contact'
get '/about-us' => 'pages#about_us'
The above routes will inspected to
When running `rake routes` you will get the following output:
Prefix Verb URI Pattern Controller#Action
contact_us GET /contact-us(.:format) pages#contact
...
...
actionpack/test/dispatch/routing/inspector_test.rb
浏览文件 @
bf191318
...
...
@@ -37,7 +37,6 @@ def self.inspect
end
engine
.
routes
.
draw
do
get
'/cart'
,
:to
=>
'cart#show'
get
'/view-cart'
,
:to
=>
'cart#show'
end
output
=
draw
do
...
...
@@ -51,8 +50,7 @@ def self.inspect
" blog /blog Blog::Engine"
,
""
,
"Routes for Blog::Engine:"
,
" cart GET /cart(.:format) cart#show"
,
"view_cart GET /view-cart(.:format) cart#show"
" cart GET /cart(.:format) cart#show"
],
output
end
...
...
@@ -162,6 +160,19 @@ def test_rake_routes_shows_route_with_constraints
],
output
end
def
test_rake_routes_shows_routes_with_dashes
output
=
draw
do
get
'about-us'
=>
'pages#about_us'
get
'our-work/latest'
end
assert_equal
[
" Prefix Verb URI Pattern Controller#Action"
,
" about_us GET /about-us(.:format) pages#about_us"
,
"our_work_latest GET /our-work/latest(.:format) our_work#latest"
],
output
end
class
RackApp
def
self
.
call
(
env
)
end
...
...
actionpack/test/dispatch/routing/route_set_test.rb
浏览文件 @
bf191318
...
...
@@ -30,12 +30,10 @@ def call(env)
draw
do
get
'foo'
,
to:
SimpleApp
.
new
(
'foo#index'
)
get
'bar'
,
to:
SimpleApp
.
new
(
'bar#index'
)
get
'foo-bar'
,
to:
SimpleApp
.
new
(
'bar#index'
)
end
assert_equal
'/foo'
,
url_helpers
.
foo_path
assert_equal
'/bar'
,
url_helpers
.
bar_path
assert_equal
'/foo-bar'
,
url_helpers
.
foo_bar_path
end
test
"url helpers are updated when route is updated"
do
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
bf191318
...
...
@@ -2912,6 +2912,16 @@ def test_trailing_slash
assert
@response
.
ok?
,
'route with trailing slash and with QUERY_STRING should work'
end
def
test_route_with_dashes_in_path
draw
do
get
'/contact-us'
,
to:
'pages#contact_us'
end
get
'/contact-us'
assert_equal
'pages#contact_us'
,
@response
.
body
assert_equal
'/contact-us'
,
contact_us_path
end
def
test_shorthand_route_with_dashes_in_path
draw
do
get
'/about-us/index'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录