Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
041c2c87
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,体验更适合开发者的 AI 搜索 >>
提交
041c2c87
编写于
4月 08, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19633 from y00rb/sort_router_parameters_duplicated_keys
avoid error when sort mixture keys in symbol and string
上级
39c7cb20
a77de098
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
2 deletion
+42
-2
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/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+13
-0
actionpack/test/journey/router_test.rb
actionpack/test/journey/router_test.rb
+27
-0
未找到文件。
actionpack/lib/action_dispatch/journey/formatter.rb
浏览文件 @
041c2c87
...
...
@@ -39,7 +39,7 @@ def generate(name, options, path_parameters, parameterize = nil)
return
[
route
.
format
(
parameterized_parts
),
params
]
end
message
=
"No route matches
#{
Hash
[
constraints
.
sort
].
inspect
}
"
message
=
"No route matches
#{
Hash
[
constraints
.
sort
_by
{
|
k
,
v
|
k
.
to_s
}
].inspect}"
message
<<
" missing required keys:
#{
missing_keys
.
sort
.
inspect
}
"
unless
missing_keys
.
empty?
raise
ActionController
::
UrlGenerationError
,
message
...
...
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
041c2c87
...
...
@@ -226,7 +226,7 @@ def raise_generation_error(args)
params
=
parameterize_args
(
args
)
{
|
missing_key
|
missing_keys
<<
missing_key
}
constraints
=
Hash
[
@route
.
requirements
.
merge
(
params
).
sort
]
constraints
=
Hash
[
@route
.
requirements
.
merge
(
params
).
sort
_by
{
|
k
,
v
|
k
.
to_s
}
]
message
=
"No route matches
#{
constraints
.
inspect
}
"
message
<<
" missing required keys:
#{
missing_keys
.
sort
.
inspect
}
"
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
041c2c87
...
...
@@ -4476,6 +4476,19 @@ def app; APP end
error
=
assert_raises
(
ActionController
::
UrlGenerationError
,
message
){
product_path
(
id:
nil
)
}
assert_equal
message
,
error
.
message
end
test
"url helpers raise message with mixed parameters when generation fails "
do
url
,
missing
=
{
action:
'show'
,
controller:
'products'
,
id:
nil
,
"id"
=>
"url-tested"
},
[
:id
]
message
=
"No route matches
#{
url
.
inspect
}
missing required keys:
#{
missing
.
inspect
}
"
# Optimized url helper
error
=
assert_raises
(
ActionController
::
UrlGenerationError
){
product_path
(
nil
,
'id'
=>
'url-tested'
)
}
assert_equal
message
,
error
.
message
# Non-optimized url helper
error
=
assert_raises
(
ActionController
::
UrlGenerationError
,
message
){
product_path
(
id:
nil
,
'id'
=>
'url-tested'
)
}
assert_equal
message
,
error
.
message
end
end
class
TestDefaultUrlOptions
<
ActionDispatch
::
IntegrationTest
...
...
actionpack/test/journey/router_test.rb
浏览文件 @
041c2c87
...
...
@@ -401,6 +401,33 @@ def test_generate_extra_params
assert_equal
({
:id
=>
1
,
:relative_url_root
=>
nil
},
params
)
end
def
test_generate_missing_keys_no_matches_different_format_keys
path
=
Path
::
Pattern
.
from_string
'/:controller/:action/:name'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
primarty_parameters
=
{
:id
=>
1
,
:controller
=>
"tasks"
,
:action
=>
"show"
,
:relative_url_root
=>
nil
}
redirection_parameters
=
{
'action'
=>
'show'
,
}
missing_key
=
'name'
missing_parameters
=
{
missing_key
=>
"task_1"
}
request_parameters
=
primarty_parameters
.
merge
(
redirection_parameters
).
merge
(
missing_parameters
)
message
=
"No route matches
#{
Hash
[
request_parameters
.
sort_by
{
|
k
,
v
|
k
.
to_s
}
].inspect} missing required keys:
#{
[
missing_key
.
to_sym
].
inspect
}
"
error
=
assert_raises
(
ActionController
::
UrlGenerationError
)
do
@formatter
.
generate
(
nil
,
request_parameters
,
request_parameters
)
end
assert_equal
message
,
error
.
message
end
def
test_generate_uses_recall_if_needed
path
=
Path
::
Pattern
.
from_string
'/:controller(/:action(/:id))'
@router
.
routes
.
add_route
@app
,
path
,
{},
{},
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录