Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7e6cda15
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,发现更多精彩内容 >>
提交
7e6cda15
编写于
9月 07, 2008
作者:
M
Matt Jones
提交者:
Joshua Peek
9月 07, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure routing optimizations are cleared when new routes are added [#981 state:resolved]
Signed-off-by:
N
Joshua Peek
<
josh@joshpeek.com
>
上级
41efd738
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
2 deletion
+41
-2
actionpack/lib/action_controller/routing/recognition_optimisation.rb
...lib/action_controller/routing/recognition_optimisation.rb
+9
-0
actionpack/lib/action_controller/routing/route_set.rb
actionpack/lib/action_controller/routing/route_set.rb
+2
-2
actionpack/test/controller/routing_test.rb
actionpack/test/controller/routing_test.rb
+30
-0
未找到文件。
actionpack/lib/action_controller/routing/recognition_optimisation.rb
浏览文件 @
7e6cda15
...
...
@@ -147,6 +147,15 @@ def recognize_optimized(path, env)
end
}
,
__FILE__
,
__LINE__
end
def
clear_recognize_optimized!
instance_eval
%{
def recognize_optimized(path, environment)
write_recognize_optimized!
recognize_optimized(path, environment)
end
}
,
__FILE__
,
__LINE__
end
end
end
end
actionpack/lib/action_controller/routing/route_set.rb
浏览文件 @
7e6cda15
...
...
@@ -195,7 +195,7 @@ def initialize
self
.
routes
=
[]
self
.
named_routes
=
NamedRouteCollection
.
new
write
_recognize_optimized!
clear
_recognize_optimized!
end
# Subclasses and plugins may override this method to specify a different
...
...
@@ -217,7 +217,7 @@ def clear!
@routes_by_controller
=
nil
# This will force routing/recognition_optimization.rb
# to refresh optimisations.
@compiled_recognize_optimized
=
nil
clear_recognize_optimized!
end
def
install_helpers
(
destinations
=
[
ActionController
::
Base
,
ActionView
::
Base
],
regenerate_code
=
false
)
...
...
actionpack/test/controller/routing_test.rb
浏览文件 @
7e6cda15
...
...
@@ -1375,6 +1375,36 @@ def test_failed_requirements_raises_exception_with_violated_requirements
x
.
send
(
:foo_with_requirement_url
,
"I am Against the requirements"
)
end
end
def
test_routes_changed_correctly_after_clear
ActionController
::
Base
.
optimise_named_routes
=
true
rs
=
::
ActionController
::
Routing
::
RouteSet
.
new
rs
.
draw
do
|
r
|
r
.
connect
'ca'
,
:controller
=>
'ca'
,
:action
=>
"aa"
r
.
connect
'cb'
,
:controller
=>
'cb'
,
:action
=>
"ab"
r
.
connect
'cc'
,
:controller
=>
'cc'
,
:action
=>
"ac"
r
.
connect
':controller/:action/:id'
r
.
connect
':controller/:action/:id.:format'
end
hash
=
rs
.
recognize_path
"/cc"
assert_not_nil
hash
assert_equal
%w(cc ac)
,
[
hash
[
:controller
],
hash
[
:action
]]
rs
.
draw
do
|
r
|
r
.
connect
'cb'
,
:controller
=>
'cb'
,
:action
=>
"ab"
r
.
connect
'cc'
,
:controller
=>
'cc'
,
:action
=>
"ac"
r
.
connect
':controller/:action/:id'
r
.
connect
':controller/:action/:id.:format'
end
hash
=
rs
.
recognize_path
"/cc"
assert_not_nil
hash
assert_equal
%w(cc ac)
,
[
hash
[
:controller
],
hash
[
:action
]]
end
end
class
RouteTest
<
Test
::
Unit
::
TestCase
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录