Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1b459916
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 搜索 >>
提交
1b459916
编写于
4月 29, 2009
作者:
Y
Yehuda Katz + Carl Lerche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed the new_base tests
上级
b692fceb
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
98 addition
and
94 deletion
+98
-94
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+2
-0
actionpack/test/new_base/base_test.rb
actionpack/test/new_base/base_test.rb
+21
-22
actionpack/test/new_base/render_template_test.rb
actionpack/test/new_base/render_template_test.rb
+37
-39
actionpack/test/new_base/render_text_test.rb
actionpack/test/new_base/render_text_test.rb
+38
-33
未找到文件。
actionpack/test/controller/render_test.rb
浏览文件 @
1b459916
...
...
@@ -106,6 +106,7 @@ def render_template_in_top_directory_with_slash
render
:template
=>
'/shared'
end
# :ported:
def
render_hello_world_from_variable
@person
=
"david"
render
:text
=>
"hello
#{
@person
}
"
...
...
@@ -123,6 +124,7 @@ def render_action_hello_world_with_symbol
render
:action
=>
:hello_world
end
# :ported:
def
render_text_hello_world
render
:text
=>
"hello world"
end
...
...
actionpack/test/new_base/base_test.rb
浏览文件 @
1b459916
require
File
.
join
(
File
.
expand_path
(
File
.
dirname
(
__FILE__
)),
"test_helper"
)
# Tests the controller dispatching happy path
module
HappyPath
class
Simple
Dispatch
Controller
<
ActionController
::
Base2
module
Dispatching
class
SimpleController
<
ActionController
::
Base2
def
index
render
:text
=>
"success"
end
...
...
@@ -23,7 +23,7 @@ def modify_response_headers
class
TestSimpleDispatch
<
SimpleRouteCase
get
"/
happy_path/simple_dispatch
/index"
get
"/
dispatching/simple
/index"
test
"sets the body"
do
assert_body
"success"
...
...
@@ -45,7 +45,7 @@ class TestSimpleDispatch < SimpleRouteCase
# :api: plugin
class
TestDirectResponseMod
<
SimpleRouteCase
get
"/
happy_path/simple_dispatch
/modify_response_body"
get
"/
dispatching/simple
/modify_response_body"
test
"sets the body"
do
assert_body
"success"
...
...
@@ -58,7 +58,7 @@ class TestDirectResponseMod < SimpleRouteCase
# :api: plugin
class
TestDirectResponseModTwice
<
SimpleRouteCase
get
"/
happy_path/simple_dispatch
/modify_response_body_twice"
get
"/
dispatching/simple
/modify_response_body_twice"
test
"self.response_body= returns the body being set"
do
assert_body
"success!"
...
...
@@ -68,23 +68,22 @@ class TestDirectResponseModTwice < SimpleRouteCase
assert_header
"Content-Length"
,
"8"
end
end
end
class
EmptyController
<
ActionController
::
Base2
;
end
module
Submodule
class
EmptyController
<
ActionController
::
Base2
;
end
module
Submodule
class
ContainedEmptyController
<
ActionController
::
Base2
;
end
end
end
class
ControllerClassTests
<
Test
::
Unit
::
TestCase
class
ControllerClassTests
<
Test
::
Unit
::
TestCase
def
test_controller_path
assert_equal
'
empty'
,
EmptyController
.
controller_path
assert_equal
'dispatching/
empty'
,
EmptyController
.
controller_path
assert_equal
EmptyController
.
controller_path
,
EmptyController
.
new
.
controller_path
assert_equal
'
submodule/contained_empty'
,
Submodule
::
ContainedEmptyController
.
controller_path
assert_equal
'dispatching/
submodule/contained_empty'
,
Submodule
::
ContainedEmptyController
.
controller_path
assert_equal
Submodule
::
ContainedEmptyController
.
controller_path
,
Submodule
::
ContainedEmptyController
.
new
.
controller_path
end
def
test_controller_name
assert_equal
'empty'
,
EmptyController
.
controller_name
assert_equal
'contained_empty'
,
Submodule
::
ContainedEmptyController
.
controller_name
end
end
end
\ No newline at end of file
actionpack/test/new_base/render_template_test.rb
浏览文件 @
1b459916
require
File
.
join
(
File
.
expand_path
(
File
.
dirname
(
__FILE__
)),
"test_helper"
)
module
HappyPath
class
RenderTemplateWithoutLayoutController
<
ActionController
::
Base2
module
RenderTemplate
class
WithoutLayoutController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
)]
def
render_hello_world
def
index
render
:template
=>
"test/basic"
end
def
render_template_
in_top_directory
def
in_top_directory
render
:template
=>
'shared'
end
def
render_template_
in_top_directory_with_slash
def
in_top_directory_with_slash
render
:template
=>
'/shared'
end
end
class
Test
TemplateRender
WithoutLayout
<
SimpleRouteCase
class
TestWithoutLayout
<
SimpleRouteCase
describe
"rendering a normal template with full path without layout"
get
"/
happy_path/render_template_without_layout/render_hello_world
"
get
"/
render_template/without_layout
"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
...
...
@@ -33,7 +32,7 @@ class TestTemplateRenderWithoutLayout < SimpleRouteCase
class
TestTemplateRenderInTopDirectory
<
SimpleRouteCase
describe
"rendering a template not in a subdirectory"
get
"/
happy_path/render_template_without_layout/render_template_
in_top_directory"
get
"/
render_template/without_layout/
in_top_directory"
assert_body
"Elastica"
assert_status
200
end
...
...
@@ -41,12 +40,12 @@ class TestTemplateRenderInTopDirectory < SimpleRouteCase
class
TestTemplateRenderInTopDirectoryWithSlash
<
SimpleRouteCase
describe
"rendering a template not in a subdirectory with a leading slash"
get
"/
happy_path/render_template_without_layout/render_template_
in_top_directory_with_slash"
get
"/
render_template/without_layout/
in_top_directory_with_slash"
assert_body
"Elastica"
assert_status
200
end
class
RenderTemplate
WithLayoutController
<
::
ApplicationController
class
WithLayoutController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
...
...
@@ -55,23 +54,23 @@ class RenderTemplateWithLayoutController < ::ApplicationController
"layouts/greetings.html.erb"
=>
"<%= yield %>, I wish thee well."
)]
def
render_hello_world
def
index
render
:template
=>
"test/basic"
end
def
render_hello_world_
with_layout
def
with_layout
render
:template
=>
"test/basic"
,
:layout
=>
true
end
def
render_hello_world_
with_layout_false
def
with_layout_false
render
:template
=>
"test/basic"
,
:layout
=>
false
end
def
render_hello_world_
with_layout_nil
def
with_layout_nil
render
:template
=>
"test/basic"
,
:layout
=>
nil
end
def
render_hello_world_
with_custom_layout
def
with_custom_layout
render
:template
=>
"test/basic"
,
:layout
=>
"greetings"
end
end
...
...
@@ -79,7 +78,7 @@ def render_hello_world_with_custom_layout
class
TestTemplateRenderWithLayout
<
SimpleRouteCase
describe
"rendering a normal template with full path with layout"
get
"/
happy_path/render_template_with_layout/render_hello_world
"
get
"/
render_template/with_layout
"
assert_body
"Hello from basic.html.erb, I'm here!"
assert_status
200
end
...
...
@@ -87,7 +86,7 @@ class TestTemplateRenderWithLayout < SimpleRouteCase
class
TestTemplateRenderWithLayoutTrue
<
SimpleRouteCase
describe
"rendering a normal template with full path with layout => :true"
get
"/
happy_path/render_template_with_layout/render_hello_world_
with_layout"
get
"/
render_template/with_layout/
with_layout"
assert_body
"Hello from basic.html.erb, I'm here!"
assert_status
200
end
...
...
@@ -95,7 +94,7 @@ class TestTemplateRenderWithLayoutTrue < SimpleRouteCase
class
TestTemplateRenderWithLayoutFalse
<
SimpleRouteCase
describe
"rendering a normal template with full path with layout => :false"
get
"/
happy_path/render_template_with_layout/render_hello_world_
with_layout_false"
get
"/
render_template/with_layout/
with_layout_false"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
...
...
@@ -103,7 +102,7 @@ class TestTemplateRenderWithLayoutFalse < SimpleRouteCase
class
TestTemplateRenderWithLayoutNil
<
SimpleRouteCase
describe
"rendering a normal template with full path with layout => :nil"
get
"/
happy_path/render_template_with_layout/render_hello_world_
with_layout_nil"
get
"/
render_template/with_layout/
with_layout_nil"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
...
...
@@ -111,21 +110,19 @@ class TestTemplateRenderWithLayoutNil < SimpleRouteCase
class
TestTemplateRenderWithCustomLayout
<
SimpleRouteCase
describe
"rendering a normal template with full path with layout => 'greetings'"
get
"/
happy_path/render_template_with_layout/render_hello_world_
with_custom_layout"
get
"/
render_template/with_layout/
with_custom_layout"
assert_body
"Hello from basic.html.erb, I wish thee well."
assert_status
200
end
end
module
Compatibility
class
RenderTemplateWithoutLayoutController
<
ActionController
::
CompatibleBase2
module
Compatibility
class
WithoutLayoutController
<
ActionController
::
CompatibleBase2
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
)]
def
render_hello_world_
with_forward_slash
def
with_forward_slash
render
:template
=>
"/test/basic"
end
end
...
...
@@ -133,8 +130,9 @@ def render_hello_world_with_forward_slash
class
TestTemplateRenderWithForwardSlash
<
SimpleRouteCase
describe
"rendering a normal template with full path starting with a leading slash"
get
"/compatibility/render_template_without_layout/render_hello_world_
with_forward_slash"
get
"/render_template/compatibility/without_layout/
with_forward_slash"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
end
end
\ No newline at end of file
actionpack/test/new_base/render_text_test.rb
浏览文件 @
1b459916
...
...
@@ -3,75 +3,80 @@
class
ApplicationController
<
ActionController
::
Base2
end
module
HappyPath
class
RenderTextWithoutLayoutsController
<
ActionController
::
Base2
module
RenderText
class
SimpleController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
]
def
render_hello_world
def
index
render
:text
=>
"hello david"
end
end
class
RenderTextWithLayoutsController
<
::
ApplicationController
class
TestSimpleTextRenderWithNoLayout
<
SimpleRouteCase
describe
"Rendering text from a action with default options renders the text with the layout"
get
"/render_text/simple"
assert_body
"hello david"
assert_status
200
end
class
WithLayoutController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/application.html.erb"
=>
"<%= yield %>, I'm here!"
,
"layouts/greetings.html.erb"
=>
"<%= yield %>, I wish thee well."
"layouts/greetings.html.erb"
=>
"<%= yield %>, I wish thee well."
,
"layouts/ivar.html.erb"
=>
"<%= yield %>, <%= @ivar %>"
)]
def
render_hello_world
def
index
render
:text
=>
"hello david"
end
def
render_
custom_code
def
custom_code
render
:text
=>
"hello world"
,
:status
=>
404
end
def
render_
with_custom_code_as_string
def
with_custom_code_as_string
render
:text
=>
"hello world"
,
:status
=>
"404 Not Found"
end
def
render_text_
with_nil
def
with_nil
render
:text
=>
nil
end
def
render_text_
with_nil_and_status
def
with_nil_and_status
render
:text
=>
nil
,
:status
=>
403
end
def
render_text_
with_false
def
with_false
render
:text
=>
false
end
def
render_text_with_layout
def
with_layout_true
render
:text
=>
"hello world"
,
:layout
=>
true
end
def
render_text_
with_layout_false
def
with_layout_false
render
:text
=>
"hello world"
,
:layout
=>
false
end
def
render_text_
with_layout_nil
def
with_layout_nil
render
:text
=>
"hello world"
,
:layout
=>
nil
end
def
render_text_
with_custom_layout
def
with_custom_layout
render
:text
=>
"hello world"
,
:layout
=>
"greetings"
end
end
class
TestSimpleTextRenderWithNoLayout
<
SimpleRouteCase
describe
"Rendering text from a action with default options renders the text with the layout"
get
"/happy_path/render_text_without_layouts/render_hello_world"
assert_body
"hello david"
assert_status
200
def
with_ivar_in_layout
@ivar
=
"hello world"
render
:text
=>
"hello world"
,
:layout
=>
"ivar"
end
end
class
TestSimpleTextRenderWithLayout
<
SimpleRouteCase
describe
"Rendering text from a action with default options renders the text without the layout"
get
"/
happy_path/render_text_with_layouts/render_hello_world
"
get
"/
render_text/with_layout
"
assert_body
"hello david"
assert_status
200
end
...
...
@@ -79,7 +84,7 @@ class TestSimpleTextRenderWithLayout < SimpleRouteCase
class
TestTextRenderWithStatus
<
SimpleRouteCase
describe
"Rendering text, while also providing a custom status code"
get
"/
happy_path/render_text_with_layouts/render_
custom_code"
get
"/
render_text/with_layout/
custom_code"
assert_body
"hello world"
assert_status
404
end
...
...
@@ -87,7 +92,7 @@ class TestTextRenderWithStatus < SimpleRouteCase
class
TestTextRenderWithNil
<
SimpleRouteCase
describe
"Rendering text with nil returns a single space character"
get
"/
happy_path/render_text_with_layouts/render_text_
with_nil"
get
"/
render_text/with_layout/
with_nil"
assert_body
" "
assert_status
200
end
...
...
@@ -95,7 +100,7 @@ class TestTextRenderWithNil < SimpleRouteCase
class
TestTextRenderWithNilAndStatus
<
SimpleRouteCase
describe
"Rendering text with nil and custom status code returns a single space character with the status"
get
"/
happy_path/render_text_with_layouts/render_text_
with_nil_and_status"
get
"/
render_text/with_layout/
with_nil_and_status"
assert_body
" "
assert_status
403
end
...
...
@@ -103,7 +108,7 @@ class TestTextRenderWithNilAndStatus < SimpleRouteCase
class
TestTextRenderWithFalse
<
SimpleRouteCase
describe
"Rendering text with false returns the string 'false'"
get
"/
happy_path/render_text_with_layouts/render_text_
with_false"
get
"/
render_text/with_layout/
with_false"
assert_body
"false"
assert_status
200
end
...
...
@@ -111,7 +116,7 @@ class TestTextRenderWithFalse < SimpleRouteCase
class
TestTextRenderWithLayoutTrue
<
SimpleRouteCase
describe
"Rendering text with :layout => true"
get
"/
happy_path/render_text_with_layouts/render_text_with_layout
"
get
"/
render_text/with_layout/with_layout_true
"
assert_body
"hello world, I'm here!"
assert_status
200
end
...
...
@@ -119,7 +124,7 @@ class TestTextRenderWithLayoutTrue < SimpleRouteCase
class
TestTextRenderWithCustomLayout
<
SimpleRouteCase
describe
"Rendering text with :layout => 'greetings'"
get
"/
happy_path/render_text_with_layouts/render_text_
with_custom_layout"
get
"/
render_text/with_layout/
with_custom_layout"
assert_body
"hello world, I wish thee well."
assert_status
200
end
...
...
@@ -127,7 +132,7 @@ class TestTextRenderWithCustomLayout < SimpleRouteCase
class
TestTextRenderWithLayoutFalse
<
SimpleRouteCase
describe
"Rendering text with :layout => false"
get
"/
happy_path/render_text_with_layouts/render_text_
with_layout_false"
get
"/
render_text/with_layout/
with_layout_false"
assert_body
"hello world"
assert_status
200
end
...
...
@@ -135,7 +140,7 @@ class TestTextRenderWithLayoutFalse < SimpleRouteCase
class
TestTextRenderWithLayoutNil
<
SimpleRouteCase
describe
"Rendering text with :layout => nil"
get
"/
happy_path/render_text_with_layouts/render_text_
with_layout_nil"
get
"/
render_text/with_layout/
with_layout_nil"
assert_body
"hello world"
assert_status
200
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录