Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5b27f1ea
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,发现更多精彩内容 >>
提交
5b27f1ea
编写于
8月 08, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a test for prepending SCRIPT_NAME to generated urls
上级
763d54b1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
88 addition
and
0 deletion
+88
-0
railties/test/path_generation_test.rb
railties/test/path_generation_test.rb
+88
-0
未找到文件。
railties/test/path_generation_test.rb
0 → 100644
浏览文件 @
5b27f1ea
# encoding: utf-8
require
'abstract_unit'
require
'active_support/core_ext/object/with_options'
require
'active_support/core_ext/object/json'
require
'rails'
require
'rails/application'
ROUTING
=
ActionDispatch
::
Routing
class
PathGenerationTest
<
ActiveSupport
::
TestCase
attr_reader
:app
class
TestSet
<
ROUTING
::
RouteSet
def
initialize
(
block
)
@block
=
block
super
()
end
class
Dispatcher
<
ROUTING
::
RouteSet
::
Dispatcher
def
initialize
(
defaults
,
set
,
block
)
super
(
defaults
)
@block
=
block
@set
=
set
end
def
controller_reference
(
controller_param
)
block
=
@block
set
=
@set
Class
.
new
(
ActionController
::
Base
)
{
include
set
.
url_helpers
define_method
(
:process
)
{
|
name
|
block
.
call
(
self
)
}
def
to_a
;
[
200
,
{},
[]];
end
}
end
end
def
dispatcher
defaults
TestSet
::
Dispatcher
.
new
defaults
,
self
,
@block
end
end
def
send_request
(
uri_or_host
,
method
,
path
,
script_name
=
nil
)
host
=
uri_or_host
.
host
unless
path
path
||=
uri_or_host
.
path
params
=
{
'PATH_INFO'
=>
path
,
'REQUEST_METHOD'
=>
method
,
'HTTP_HOST'
=>
host
}
params
[
'SCRIPT_NAME'
]
=
script_name
if
script_name
status
,
headers
,
body
=
app
.
call
(
params
)
new_body
=
[]
body
.
each
{
|
part
|
new_body
<<
part
}
body
.
close
if
body
.
respond_to?
:close
[
status
,
headers
,
new_body
]
end
def
test_original_script_name
original_logger
=
Rails
.
logger
Rails
.
logger
=
Logger
.
new
nil
app
=
Class
.
new
(
Rails
::
Application
)
{
attr_accessor
:controller
def
initialize
super
app
=
self
@routes
=
TestSet
.
new
->
(
c
)
{
app
.
controller
=
c
}
secrets
.
secret_key_base
=
"foo"
secrets
.
secret_token
=
"foo"
end
def
app
;
routes
;
end
}
@app
=
app
app
.
routes
.
draw
{
resource
:blogs
}
url
=
URI
(
"http://example.org/blogs"
)
send_request
(
url
,
'GET'
,
nil
,
'/FOO'
)
assert_equal
'/FOO/blogs'
,
app
.
instance
.
controller
.
blogs_path
send_request
(
url
,
'GET'
,
nil
)
assert_equal
'/blogs'
,
app
.
instance
.
controller
.
blogs_path
ensure
Rails
.
logger
=
original_logger
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录