Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
43e0bc1c
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,发现更多精彩内容 >>
提交
43e0bc1c
编写于
10月 27, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract routing controller stub helper into abstract unit
上级
e296ea05
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
86 addition
and
79 deletion
+86
-79
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+20
-0
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+66
-79
未找到文件。
actionpack/test/abstract_unit.rb
浏览文件 @
43e0bc1c
...
...
@@ -105,6 +105,26 @@ def self.build_app(routes = nil)
self
.
app
=
build_app
class
StubDispatcher
def
self
.
new
(
*
args
)
lambda
{
|
env
|
params
=
env
[
'action_dispatch.request.path_parameters'
]
controller
,
action
=
params
[
:controller
],
params
[
:action
]
[
200
,
{
'Content-Type'
=>
'text/html'
},
[
"
#{
controller
}
#
#{
action
}
"
]]
}
end
end
def
self
.
stub_controllers
old_dispatcher
=
ActionDispatch
::
Routing
::
RouteSet
::
Dispatcher
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
StubDispatcher
}
yield
ActionDispatch
::
Routing
::
RouteSet
.
new
ensure
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
old_dispatcher
}
end
def
with_routing
(
&
block
)
real_routes
=
ActionController
::
Routing
::
Routes
ActionController
::
Routing
.
module_eval
{
remove_const
:Routes
}
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
43e0bc1c
...
...
@@ -12,112 +12,99 @@ def self.matches?(request)
end
end
class
Dispatcher
def
self
.
new
(
*
args
)
lambda
{
|
env
|
params
=
env
[
'action_dispatch.request.path_parameters'
]
controller
,
action
=
params
[
:controller
],
params
[
:action
]
[
200
,
{
'Content-Type'
=>
'text/html'
},
[
"
#{
controller
}
#
#{
action
}
"
]]
}
end
end
old_dispatcher
=
ActionDispatch
::
Routing
::
RouteSet
::
Dispatcher
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
Dispatcher
}
Routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
Routes
.
draw
do
|
map
|
controller
:sessions
do
get
'login'
,
:to
=>
:new
,
:as
=>
:login
post
'login'
,
:to
=>
:create
delete
'logout'
,
:to
=>
:destroy
,
:as
=>
:logout
end
match
'account/login'
,
:to
=>
redirect
(
"/login"
)
match
'openid/login'
,
:via
=>
[
:get
,
:post
],
:to
=>
"openid#login"
controller
(
:global
)
do
match
'global/:action'
match
'global/export'
,
:to
=>
:export
,
:as
=>
:export_request
match
'global/hide_notice'
,
:to
=>
:hide_notice
,
:as
=>
:hide_notice
match
'/export/:id/:file'
,
:to
=>
:export
,
:as
=>
:export_download
,
:constraints
=>
{
:file
=>
/.*/
}
end
constraints
(
:ip
=>
/192\.168\.1\.\d\d\d/
)
do
get
'admin'
,
:to
=>
"queenbee#index"
end
stub_controllers
do
|
routes
|
Routes
=
routes
Routes
.
draw
do
|
map
|
controller
:sessions
do
get
'login'
,
:to
=>
:new
,
:as
=>
:login
post
'login'
,
:to
=>
:create
delete
'logout'
,
:to
=>
:destroy
,
:as
=>
:logout
end
constraints
IpRestrictor
do
get
'admin/accounts'
,
:to
=>
"queenbee#accounts"
end
match
'account/login'
,
:to
=>
redirect
(
"/login"
)
resources
:projects
,
:controller
=>
:project
do
resources
:involvements
,
:attachments
match
'openid/login'
,
:via
=>
[
:get
,
:post
],
:to
=>
"openid#login"
resources
:participants
do
put
:update_all
,
:on
=>
:collection
controller
(
:global
)
do
match
'global/:action'
match
'global/export'
,
:to
=>
:export
,
:as
=>
:export_request
match
'global/hide_notice'
,
:to
=>
:hide_notice
,
:as
=>
:hide_notice
match
'/export/:id/:file'
,
:to
=>
:export
,
:as
=>
:export_download
,
:constraints
=>
{
:file
=>
/.*/
}
end
resources
:companies
do
resources
:people
resource
:avatar
constraints
(
:ip
=>
/192\.168\.1\.\d\d\d/
)
do
get
'admin'
,
:to
=>
"queenbee#index"
end
resources
:images
do
post
:revise
,
:on
=>
:member
constraints
IpRestrictor
do
get
'admin/accounts'
,
:to
=>
"queenbee#accounts"
end
resources
:people
do
namespace
":access_token"
do
resource
:avatar
resources
:projects
,
:controller
=>
:project
do
resources
:involvements
,
:attachments
resources
:participants
do
put
:update_all
,
:on
=>
:collection
end
member
do
put
:accessible_projects
post
:resend
,
:generate_new_password
resources
:companies
do
resources
:people
resource
:avatar
end
resources
:images
do
post
:revise
,
:on
=>
:member
end
resources
:people
do
namespace
":access_token"
do
resource
:avatar
end
member
do
put
:accessible_projects
post
:resend
,
:generate_new_password
end
end
end
resources
:posts
do
get
:archive
,
:toggle_view
,
:on
=>
:collection
post
:preview
,
:on
=>
:member
resources
:posts
do
get
:archive
,
:toggle_view
,
:on
=>
:collection
post
:preview
,
:on
=>
:member
resource
:subscription
resource
:subscription
resources
:comments
do
post
:preview
,
:on
=>
:collection
resources
:comments
do
post
:preview
,
:on
=>
:collection
end
end
end
end
match
'sprockets.js'
,
:to
=>
SprocketsApp
match
'sprockets.js'
,
:to
=>
SprocketsApp
match
'people/:id/update'
,
:to
=>
'people#update'
,
:as
=>
:update_person
match
'/projects/:project_id/people/:id/update'
,
:to
=>
'people#update'
,
:as
=>
:update_project_person
match
'people/:id/update'
,
:to
=>
'people#update'
,
:as
=>
:update_person
match
'/projects/:project_id/people/:id/update'
,
:to
=>
'people#update'
,
:as
=>
:update_project_person
# misc
match
'articles/:year/:month/:day/:title'
,
:to
=>
"articles#show"
,
:as
=>
:article
# misc
match
'articles/:year/:month/:day/:title'
,
:to
=>
"articles#show"
,
:as
=>
:article
namespace
:account
do
resource
:subscription
,
:credit
,
:credit_card
end
namespace
:account
do
resource
:subscription
,
:credit
,
:credit_card
end
controller
:articles
do
scope
'articles'
do
scope
':title'
,
:title
=>
/[a-z]+/
,
:as
=>
:with_title
do
match
':id'
,
:to
=>
:with_id
controller
:articles
do
scope
'articles'
do
scope
':title'
,
:title
=>
/[a-z]+/
,
:as
=>
:with_title
do
match
':id'
,
:to
=>
:with_id
end
end
end
end
scope
':access_token'
,
:constraints
=>
{
:access_token
=>
/\w{5,5}/
}
do
resources
:rooms
scope
':access_token'
,
:constraints
=>
{
:access_token
=>
/\w{5,5}/
}
do
resources
:rooms
end
end
end
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
old_dispatcher
}
def
app
Routes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录