Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
089d9baa
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,发现更多精彩内容 >>
提交
089d9baa
编写于
5月 20, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
we don't use this parameter for anything, so rm
上级
ba487b9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
22 deletion
+21
-22
actionpack/lib/action_dispatch/journey/formatter.rb
actionpack/lib/action_dispatch/journey/formatter.rb
+1
-1
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+1
-1
actionpack/test/journey/router_test.rb
actionpack/test/journey/router_test.rb
+19
-20
未找到文件。
actionpack/lib/action_dispatch/journey/formatter.rb
浏览文件 @
089d9baa
...
...
@@ -12,7 +12,7 @@ def initialize(routes)
@cache
=
nil
end
def
generate
(
type
,
name
,
options
,
recall
=
{},
parameterize
=
nil
)
def
generate
(
name
,
options
,
recall
=
{},
parameterize
=
nil
)
constraints
=
recall
.
merge
(
options
)
missing_keys
=
[]
...
...
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
089d9baa
...
...
@@ -600,7 +600,7 @@ def normalize_action!
# Generates a path from routes, returns [path, params].
# If no route is generated the formatter will raise ActionController::UrlGenerationError
def
generate
@set
.
formatter
.
generate
(
:path_info
,
named_route
,
options
,
recall
,
PARAMETERIZE
)
@set
.
formatter
.
generate
(
named_route
,
options
,
recall
,
PARAMETERIZE
)
end
def
different_controller?
...
...
actionpack/test/journey/router_test.rb
浏览文件 @
089d9baa
...
...
@@ -160,7 +160,7 @@ def test_required_parts_verified_are_anchored
]
assert_raises
(
ActionController
::
UrlGenerationError
)
do
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
'10'
},
{
})
@formatter
.
generate
(
nil
,
{
:id
=>
'10'
},
{
})
end
end
...
...
@@ -169,11 +169,11 @@ def test_required_parts_are_verified_when_building
Router
::
Strexp
.
new
(
"/foo/:id"
,
{
:id
=>
/\d+/
},
[
'/'
,
'.'
,
'?'
],
false
)
]
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
'10'
},
{
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
:id
=>
'10'
},
{
})
assert_equal
'/foo/10'
,
path
assert_raises
(
ActionController
::
UrlGenerationError
)
do
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
'aa'
},
{
})
@formatter
.
generate
(
nil
,
{
:id
=>
'aa'
},
{
})
end
end
...
...
@@ -182,13 +182,13 @@ def test_only_required_parts_are_verified
Router
::
Strexp
.
new
(
"/foo(/:id)"
,
{
:id
=>
/\d/
},
[
'/'
,
'.'
,
'?'
],
false
)
]
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
'10'
},
{
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
:id
=>
'10'
},
{
})
assert_equal
'/foo/10'
,
path
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
},
{
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
},
{
})
assert_equal
'/foo'
,
path
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
'aa'
},
{
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
:id
=>
'aa'
},
{
})
assert_equal
'/foo/aa'
,
path
end
...
...
@@ -199,7 +199,7 @@ def test_knows_what_parts_are_missing_from_named_route
@router
.
routes
.
add_route
nil
,
path
,
{},
{},
route_name
error
=
assert_raises
(
ActionController
::
UrlGenerationError
)
do
@formatter
.
generate
(
:path_info
,
route_name
,
{
},
{
})
@formatter
.
generate
(
route_name
,
{
},
{
})
end
assert_match
(
/missing required keys: \[:id\]/
,
error
.
message
)
...
...
@@ -287,14 +287,14 @@ def test_path_not_found
def
test_required_part_in_recall
add_routes
@router
,
[
"/messages/:a/:b"
]
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:a
=>
'a'
},
{
:b
=>
'b'
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
:a
=>
'a'
},
{
:b
=>
'b'
})
assert_equal
"/messages/a/b"
,
path
end
def
test_splat_in_recall
add_routes
@router
,
[
"/*path"
]
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
},
{
:path
=>
'b'
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
},
{
:path
=>
'b'
})
assert_equal
"/b"
,
path
end
...
...
@@ -304,7 +304,7 @@ def test_recall_should_be_used_when_scoring
"/messages/:id(.:format)"
]
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
10
},
{
:action
=>
'index'
})
path
,
_
=
@formatter
.
generate
(
nil
,
{
:id
=>
10
},
{
:action
=>
'index'
})
assert_equal
"/messages/index/10"
,
path
end
...
...
@@ -315,7 +315,7 @@ def test_nil_path_parts_are_ignored
params
=
{
:controller
=>
"tasks"
,
:format
=>
nil
}
extras
=
{
:action
=>
'lol'
}
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
params
,
extras
)
path
,
_
=
@formatter
.
generate
(
nil
,
params
,
extras
)
assert_equal
'/tasks'
,
path
end
...
...
@@ -327,7 +327,7 @@ def test_generate_slash
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
Hash
[
params
],
{})
path
,
_
=
@formatter
.
generate
(
nil
,
Hash
[
params
],
{})
assert_equal
'/'
,
path
end
...
...
@@ -340,7 +340,6 @@ def test_generate_calls_param_proc
[
:action
,
"show"
]
]
@formatter
.
generate
(
:path_info
,
nil
,
Hash
[
params
],
{},
...
...
@@ -354,7 +353,7 @@ def test_generate_id
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
params
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:id
=>
1
,
:controller
=>
"tasks"
,
:action
=>
"show"
},
{})
nil
,
{
:id
=>
1
,
:controller
=>
"tasks"
,
:action
=>
"show"
},
{})
assert_equal
'/tasks/show'
,
path
assert_equal
({
:id
=>
1
},
params
)
end
...
...
@@ -363,8 +362,8 @@ def test_generate_escapes
path
=
Path
::
Pattern
.
new
'/:controller(/:action)'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
_
=
@formatter
.
generate
(
:path_info
,
nil
,
{
:controller
=>
"tasks"
,
path
,
_
=
@formatter
.
generate
(
nil
,
{
:controller
=>
"tasks"
,
:action
=>
"a/b c+d"
,
},
{})
assert_equal
'/tasks/a%2Fb%20c+d'
,
path
...
...
@@ -374,7 +373,7 @@ def test_generate_escapes_with_namespaced_controller
path
=
Path
::
Pattern
.
new
'/:controller(/:action)'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
_
=
@formatter
.
generate
(
:path_info
,
path
,
_
=
@formatter
.
generate
(
nil
,
{
:controller
=>
"admin/tasks"
,
:action
=>
"a/b c+d"
,
},
{})
...
...
@@ -385,7 +384,7 @@ def test_generate_extra_params
path
=
Path
::
Pattern
.
new
'/:controller(/:action)'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
params
=
@formatter
.
generate
(
:path_info
,
path
,
params
=
@formatter
.
generate
(
nil
,
{
:id
=>
1
,
:controller
=>
"tasks"
,
:action
=>
"show"
,
...
...
@@ -399,7 +398,7 @@ def test_generate_uses_recall_if_needed
path
=
Path
::
Pattern
.
new
'/:controller(/:action(/:id))'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
params
=
@formatter
.
generate
(
:path_info
,
path
,
params
=
@formatter
.
generate
(
nil
,
{
:controller
=>
"tasks"
,
:id
=>
10
},
{
:action
=>
"index"
})
...
...
@@ -411,7 +410,7 @@ def test_generate_with_name
path
=
Path
::
Pattern
.
new
'/:controller(/:action)'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
path
,
params
=
@formatter
.
generate
(
:path_info
,
path
,
params
=
@formatter
.
generate
(
"tasks"
,
{
:controller
=>
"tasks"
},
{
:controller
=>
"tasks"
,
:action
=>
"index"
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录