Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
90c079a7
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 搜索 >>
提交
90c079a7
编写于
3月 20, 2009
作者:
C
Carl Lerche
提交者:
Yehuda Katz
3月 23, 2009
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modified the action layout tests to use the new FixtureTemplate class
上级
dc96ba80
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
89 addition
and
26 deletion
+89
-26
actionpack/test/new_base/fixture_view_path_test.rb
actionpack/test/new_base/fixture_view_path_test.rb
+40
-15
actionpack/test/new_base/render_action_test.rb
actionpack/test/new_base/render_action_test.rb
+13
-4
actionpack/test/new_base/test_helper.rb
actionpack/test/new_base/test_helper.rb
+36
-0
actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb
...happy_path/render_action_with_layout/hello_world.html.erb
+0
-1
actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb
...iews/with_application_layout/layouts/application.html.erb
+0
-1
actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb
..._action_with_controller_layout_first/hello_world.html.erb
+0
-1
actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb
...base/views/with_both_layouts/layouts/application.html.erb
+0
-1
actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb
..._path/render_action_with_controller_layout_first.html.erb
+0
-1
actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb
...render_action_with_controller_layout/hello_world.html.erb
+0
-1
actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb
.../happy_path/render_action_with_controller_layout.html.erb
+0
-1
未找到文件。
actionpack/test/new_base/fixture_view_path_test.rb
浏览文件 @
90c079a7
...
...
@@ -18,30 +18,28 @@ def find_template(path)
end
end
def
initialize
(
body
,
template_path
,
load_paths
=
[]
)
def
initialize
(
body
,
*
args
)
@body
=
body
end
def
relative_path
"fail"
end
def
filename
"fail"
end
def
method_name_without_locals
"abc"
super
(
*
args
)
end
def
source
@body
end
private
def
find_full_path
(
path
,
load_paths
)
return
'/'
,
path
end
end
end
OMG
=
{
"happy_path/render_action/hello_world.html.erb"
=>
"Hello world!"
"happy_path/render_action/hello_world.html.erb"
=>
"Hello world!"
,
"happy_path/render_action/goodbye_world.html.erb"
=>
"Goodbye world!"
,
"happy_path/sexy_time/borat.html.erb"
=>
"I LIKE!!!"
}
module
HappyPath
...
...
@@ -55,9 +53,21 @@ def render_action_hello_world
render
:action
=>
"hello_world"
end
def
render_action_goodbye_world
render
:action
=>
"goodbye_world"
end
end
class
TestRenderAction
<
SimpleRouteCase
class
SexyTimeController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
FixtureTemplate
::
FixturePath
.
new
(
OMG
)]
def
borat
render
"borat"
end
end
class
TestRenderHelloAction
<
SimpleRouteCase
describe
"Rendering an action using :action => <String>"
...
...
@@ -66,4 +76,19 @@ class TestRenderAction < SimpleRouteCase
assert_status
200
end
class
TestRenderGoodbyeAction
<
SimpleRouteCase
describe
"Goodbye"
get
"/happy_path/render_action/render_action_goodbye_world"
assert_body
"Goodbye world!"
assert_status
200
end
class
TestRenderBorat
<
SimpleRouteCase
describe
"Borat yo"
get
"/happy_path/sexy_time/borat"
assert_body
"I LIKE!!!"
assert_status
200
end
end
\ No newline at end of file
actionpack/test/new_base/render_action_test.rb
浏览文件 @
90c079a7
...
...
@@ -77,7 +77,10 @@ class TestRenderActionWithSymbol < SimpleRouteCase
class
RenderActionWithLayoutController
<
ActionController
::
Base2
# Set the view path to an application view structure with layouts
self
.
view_paths
=
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'views'
,
'with_application_layout'
)]
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
FixtureTemplate
::
FixturePath
.
new
({
"happy_path/render_action_with_layout/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
})]
def
hello_world
render
:action
=>
"hello_world"
...
...
@@ -85,7 +88,10 @@ def hello_world
end
class
RenderActionWithControllerLayoutController
<
ActionController
::
Base2
self
.
view_paths
=
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'views'
,
'with_controller_layout'
)]
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
FixtureTemplate
::
FixturePath
.
new
({
"happy_path/render_action_with_controller_layout/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/happy_path/render_action_with_controller_layout.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
})]
def
hello_world
render
:action
=>
"hello_world"
...
...
@@ -93,7 +99,11 @@ def hello_world
end
class
RenderActionWithControllerLayoutFirstController
<
ActionController
::
Base2
self
.
view_paths
=
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'views'
,
'with_both_layouts'
)]
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
FixtureTemplate
::
FixturePath
.
new
({
"happy_path/render_action_with_controller_layout_first/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
,
"layouts/happy_path/render_action_with_controller_layout_first.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
})]
def
hello_world
render
:action
=>
"hello_world"
...
...
@@ -127,5 +137,4 @@ class TestRenderActionWithControllerLayoutFirst < SimpleRouteCase
assert_status
200
end
# TODO: Implement a FixtureViewPath
end
\ No newline at end of file
actionpack/test/new_base/test_helper.rb
浏览文件 @
90c079a7
...
...
@@ -50,6 +50,42 @@ def self.subclasses
end
end
module
ActionView
#:nodoc:
class
FixtureTemplate
<
Template
class
FixturePath
<
Template
::
Path
def
initialize
(
hash
)
@hash
=
{}
hash
.
each
do
|
k
,
v
|
@hash
[
k
.
sub
(
/\.\w+$/
,
''
)]
=
FixtureTemplate
.
new
(
v
,
k
.
split
(
"/"
).
last
,
self
)
end
super
(
""
)
end
def
find_template
(
path
)
@hash
[
path
]
end
end
def
initialize
(
body
,
*
args
)
@body
=
body
super
(
*
args
)
end
def
source
@body
end
private
def
find_full_path
(
path
,
load_paths
)
return
'/'
,
path
end
end
end
# Temporary base class
class
Rack::TestCase
<
ActiveSupport
::
TestCase
include
Rack
::
Test
::
Methods
...
...
actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
Hello World!
\ No newline at end of file
actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
OHAI
<%=
yield
%>
KTHXBAI
\ No newline at end of file
actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
Hello World!
\ No newline at end of file
actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
OHAI
<%=
yield
%>
KTHXBAI
\ No newline at end of file
actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
With Controller Layout!
<%=
yield
%>
KTHXBAI
\ No newline at end of file
actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
Hello World!
\ No newline at end of file
actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb
已删除
100644 → 0
浏览文件 @
dc96ba80
With Controller Layout!
<%=
yield
%>
KTHXBAI
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录