Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0cf16ddb
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,发现更多精彩内容 >>
提交
0cf16ddb
编写于
10月 21, 2009
作者:
J
José Valim
提交者:
Yehuda Katz
11月 01, 2009
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve AbstractController layouts coverage.
上级
2d514e53
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
17 deletion
+53
-17
actionpack/lib/abstract_controller/rendering_controller.rb
actionpack/lib/abstract_controller/rendering_controller.rb
+6
-3
actionpack/lib/action_controller/metal/rendering_controller.rb
...npack/lib/action_controller/metal/rendering_controller.rb
+4
-0
actionpack/lib/action_view/template/text.rb
actionpack/lib/action_view/template/text.rb
+2
-2
actionpack/test/abstract/layouts_test.rb
actionpack/test/abstract/layouts_test.rb
+41
-12
未找到文件。
actionpack/lib/abstract_controller/rendering_controller.rb
浏览文件 @
0cf16ddb
...
...
@@ -8,9 +8,7 @@ module RenderingController
included
do
attr_internal
:formats
extlib_inheritable_accessor
:_view_paths
self
.
_view_paths
||=
ActionView
::
PathSet
.
new
end
...
...
@@ -99,6 +97,7 @@ def self.body_to_s(body)
end
private
# Take in a set of options and determine the template to render
#
# ==== Options
...
...
@@ -110,7 +109,7 @@ def self.body_to_s(body)
# _partial<TrueClass, FalseClass>:: Whether or not the file to look up is a partial
def
_determine_template
(
options
)
if
options
.
key?
(
:text
)
options
[
:_template
]
=
ActionView
::
TextTemplate
.
new
(
options
[
:text
],
format
s
.
firs
t
)
options
[
:_template
]
=
ActionView
::
TextTemplate
.
new
(
options
[
:text
],
format
_for_tex
t
)
elsif
options
.
key?
(
:inline
)
handler
=
ActionView
::
Template
.
handler_class_for_extension
(
options
[
:type
]
||
"erb"
)
template
=
ActionView
::
Template
.
new
(
options
[
:inline
],
"inline
#{
options
[
:inline
].
inspect
}
"
,
handler
,
{})
...
...
@@ -147,6 +146,10 @@ def with_template_cache(name)
yield
end
def
format_for_text
Mime
[
:text
]
end
module
ClassMethods
def
clear_template_caches!
end
...
...
actionpack/lib/action_controller/metal/rendering_controller.rb
浏览文件 @
0cf16ddb
...
...
@@ -65,6 +65,10 @@ def _prefix
controller_path
end
def
format_for_text
formats
.
first
end
def
with_template_cache
(
name
)
self
.
class
.
template_cache
[
Thread
.
current
[
:format_locale_key
]][
name
]
||=
super
end
...
...
actionpack/lib/action_view/template/text.rb
浏览文件 @
0cf16ddb
...
...
@@ -16,11 +16,11 @@ def identifier
end
def
inspect
'
inline
template'
'
text
template'
end
def
render
(
*
args
)
self
to_s
end
def
mime_type
...
...
actionpack/test/abstract/layouts_test.rb
浏览文件 @
0cf16ddb
...
...
@@ -17,17 +17,6 @@ class Base < AbstractController::Base
"layouts/omg.erb"
=>
"OMGHI2U <%= yield %>"
,
"layouts/with_false_layout.erb"
=>
"False Layout <%= yield %>"
)]
def
self
.
controller_path
@controller_path
||=
self
.
name
.
sub
(
/Controller$/
,
''
).
underscore
end
def
controller_path
()
self
.
class
.
controller_path
end
def
render_to_body
(
options
)
options
[
:_layout
]
=
_default_layout
({})
super
end
end
class
Blank
<
Base
...
...
@@ -44,6 +33,22 @@ class WithString < Base
def
index
render
:_template
=>
ActionView
::
TextTemplate
.
new
(
"Hello string!"
)
end
def
overwrite_default
render
:_template
=>
ActionView
::
TextTemplate
.
new
(
"Hello string!"
),
:layout
=>
:default
end
def
overwrite_false
render
:_template
=>
ActionView
::
TextTemplate
.
new
(
"Hello string!"
),
:layout
=>
false
end
def
overwrite_string
render
:_template
=>
ActionView
::
TextTemplate
.
new
(
"Hello string!"
),
:layout
=>
"omg"
end
def
overwrite_skip
render
:text
=>
"Hello text!"
end
end
class
WithStringChild
<
WithString
...
...
@@ -153,7 +158,31 @@ class TestBase < ActiveSupport::TestCase
controller
.
process
(
:index
)
assert_equal
"With String Hello string!"
,
controller
.
response_body
end
test
"when layout is overwriten by :default in render, render default layout"
do
controller
=
WithString
.
new
controller
.
process
(
:overwrite_default
)
assert_equal
"With String Hello string!"
,
controller
.
response_body
end
test
"when layout is overwriten by string in render, render new layout"
do
controller
=
WithString
.
new
controller
.
process
(
:overwrite_string
)
assert_equal
"OMGHI2U Hello string!"
,
controller
.
response_body
end
test
"when layout is overwriten by false in render, render no layout"
do
controller
=
WithString
.
new
controller
.
process
(
:overwrite_false
)
assert_equal
"Hello string!"
,
controller
.
response_body
end
test
"when text is rendered, render no layout"
do
controller
=
WithString
.
new
controller
.
process
(
:overwrite_skip
)
assert_equal
"Hello text!"
,
controller
.
response_body
end
test
"when layout is specified as a string, but the layout is missing, raise an exception"
do
assert_raises
(
ActionView
::
MissingTemplate
)
{
WithMissingLayout
.
new
.
process
(
:index
)
}
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录