Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
030dfe3f
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 搜索 >>
提交
030dfe3f
编写于
5月 11, 2009
作者:
Y
Yehuda Katz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More community code review :)
上级
9047c980
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
43 deletion
+37
-43
actionpack/lib/action_controller/abstract/base.rb
actionpack/lib/action_controller/abstract/base.rb
+1
-2
actionpack/lib/action_controller/abstract/helpers.rb
actionpack/lib/action_controller/abstract/helpers.rb
+1
-8
actionpack/lib/action_controller/abstract/renderer.rb
actionpack/lib/action_controller/abstract/renderer.rb
+2
-2
actionpack/lib/action_view/template/text.rb
actionpack/lib/action_view/template/text.rb
+2
-0
actionpack/test/abstract_controller/abstract_controller_test.rb
...pack/test/abstract_controller/abstract_controller_test.rb
+10
-10
actionpack/test/abstract_controller/callbacks_test.rb
actionpack/test/abstract_controller/callbacks_test.rb
+9
-9
actionpack/test/abstract_controller/helper_test.rb
actionpack/test/abstract_controller/helper_test.rb
+1
-1
actionpack/test/abstract_controller/layouts_test.rb
actionpack/test/abstract_controller/layouts_test.rb
+11
-11
未找到文件。
actionpack/lib/action_controller/abstract/base.rb
浏览文件 @
030dfe3f
...
...
@@ -54,7 +54,6 @@ def process(action_name)
@_action_name
=
action_name
process_action
self
.
response_obj
[
:body
]
=
self
.
response_body
self
end
...
...
@@ -71,7 +70,7 @@ def action_methods
# action_name is found.
def
process_action
if
respond_to?
(
action_name
)
then
send
(
action_name
)
elsif
respond_to?
(
:action_missing
,
true
)
then
send
(
:action_missing
,
action_name
)
elsif
respond_to?
(
:action_missing
,
true
)
then
action_missing
(
action_name
)
end
end
...
...
actionpack/lib/action_controller/abstract/helpers.rb
浏览文件 @
030dfe3f
...
...
@@ -6,14 +6,7 @@ module Helpers
extlib_inheritable_accessor
:master_helper_module
self
.
master_helper_module
=
Module
.
new
end
# def self.included(klass)
# klass.class_eval do
# extlib_inheritable_accessor :master_helper_module
# self.master_helper_module = Module.new
# end
# end
def
_action_view
@_action_view
||=
begin
av
=
super
...
...
actionpack/lib/action_controller/abstract/renderer.rb
浏览文件 @
030dfe3f
...
...
@@ -20,13 +20,13 @@ module Renderer
self
.
_view_paths
||=
ActionView
::
PathSet
.
new
end
def
_action_view
@_action_view
||=
ActionView
::
Base
.
new
(
self
.
class
.
view_paths
,
{},
self
)
end
def
render
(
options
=
{})
unless
response_body
.
nil?
if
response_body
raise
AbstractController
::
DoubleRenderError
,
"OMG"
end
...
...
actionpack/lib/action_view/template/text.rb
浏览文件 @
030dfe3f
module
ActionView
#:nodoc:
class
TextTemplate
<
String
#:nodoc:
def
identifier
()
self
end
def
render
(
*
)
self
end
...
...
actionpack/test/abstract_controller/abstract_controller_test.rb
浏览文件 @
030dfe3f
...
...
@@ -20,7 +20,7 @@ def index
class
TestBasic
<
ActiveSupport
::
TestCase
test
"dispatching works"
do
result
=
Me
.
process
(
:index
)
assert_equal
"Hello world"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello world"
,
result
.
response_
body
end
end
...
...
@@ -69,27 +69,27 @@ def rendering_to_string
class
TestRenderer
<
ActiveSupport
::
TestCase
test
"rendering templates works"
do
result
=
Me2
.
process
(
:index
)
assert_equal
"Hello from index.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from index.erb"
,
result
.
response_
body
end
test
"rendering passes ivars to the view"
do
result
=
Me2
.
process
(
:action_with_ivars
)
assert_equal
"Hello from index_with_ivars.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from index_with_ivars.erb"
,
result
.
response_
body
end
test
"rendering with no template name"
do
result
=
Me2
.
process
(
:naked_render
)
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
body
end
test
"rendering to a rack body"
do
result
=
Me2
.
process
(
:rendering_to_body
)
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
body
end
test
"rendering to a string"
do
result
=
Me2
.
process
(
:rendering_to_string
)
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from naked_render.erb"
,
result
.
response_
body
end
end
...
...
@@ -121,12 +121,12 @@ def formatted
class
TestPrefixedViews
<
ActiveSupport
::
TestCase
test
"templates are located inside their 'prefix' folder"
do
result
=
Me3
.
process
(
:index
)
assert_equal
"Hello from me3/index.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from me3/index.erb"
,
result
.
response_
body
end
test
"templates included their format"
do
result
=
Me3
.
process
(
:formatted
)
assert_equal
"Hello from me3/formatted.html.erb"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello from me3/formatted.html.erb"
,
result
.
response_
body
end
end
...
...
@@ -174,7 +174,7 @@ def index
class
TestLayouts
<
ActiveSupport
::
TestCase
test
"layouts are included"
do
result
=
Me4
.
process
(
:index
)
assert_equal
"Me4 Enter : Hello from me4/index.erb : Exit"
,
result
.
response_
obj
[
:body
]
assert_equal
"Me4 Enter : Hello from me4/index.erb : Exit"
,
result
.
response_
body
end
end
...
...
@@ -211,7 +211,7 @@ def respond_to_action?(action_name)
class
TestRespondToAction
<
ActiveSupport
::
TestCase
def
assert_dispatch
(
klass
,
body
=
"success"
,
action
=
:index
)
response
=
klass
.
process
(
action
).
response_
obj
[
:body
]
response
=
klass
.
process
(
action
).
response_
body
assert_equal
body
,
response
end
...
...
actionpack/test/abstract_controller/callbacks_test.rb
浏览文件 @
030dfe3f
...
...
@@ -22,7 +22,7 @@ def index
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"basic callbacks work"
do
result
=
Callback1
.
process
(
:index
)
assert_equal
"Hello world"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello world"
,
result
.
response_
body
end
end
...
...
@@ -53,7 +53,7 @@ def index
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"before_filter works"
do
result
=
Callback2
.
process
(
:index
)
assert_equal
"Hello world"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello world"
,
result
.
response_
body
end
test
"after_filter works"
do
...
...
@@ -84,7 +84,7 @@ def index
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"before_filter works with procs"
do
result
=
Callback3
.
process
(
:index
)
assert_equal
"Hello world"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello world"
,
result
.
response_
body
end
test
"after_filter works with procs"
do
...
...
@@ -119,12 +119,12 @@ def authenticate
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"when :only is specified, a before filter is triggered on that action"
do
result
=
CallbacksWithConditions
.
process
(
:index
)
assert_equal
"Hello, World"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello, World"
,
result
.
response_
body
end
test
"when :only is specified, a before filter is not triggered on other actions"
do
result
=
CallbacksWithConditions
.
process
(
:sekrit_data
)
assert_equal
"true"
,
result
.
response_
obj
[
:body
]
assert_equal
"true"
,
result
.
response_
body
end
test
"when :except is specified, an after filter is not triggered on that action"
do
...
...
@@ -159,12 +159,12 @@ def authenticate
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"when :only is specified with an array, a before filter is triggered on that action"
do
result
=
CallbacksWithArrayConditions
.
process
(
:index
)
assert_equal
"Hello, World"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello, World"
,
result
.
response_
body
end
test
"when :only is specified with an array, a before filter is not triggered on other actions"
do
result
=
CallbacksWithArrayConditions
.
process
(
:sekrit_data
)
assert_equal
"true"
,
result
.
response_
obj
[
:body
]
assert_equal
"true"
,
result
.
response_
body
end
test
"when :except is specified with an array, an after filter is not triggered on that action"
do
...
...
@@ -184,12 +184,12 @@ def not_index
class
TestCallbacks
<
ActiveSupport
::
TestCase
test
"when a callback is modified in a child with :only, it works for the :only action"
do
result
=
ChangedConditions
.
process
(
:index
)
assert_equal
"Hello world"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello world"
,
result
.
response_
body
end
test
"when a callback is modified in a child with :only, it does not work for other actions"
do
result
=
ChangedConditions
.
process
(
:not_index
)
assert_equal
""
,
result
.
response_
obj
[
:body
]
assert_equal
""
,
result
.
response_
body
end
end
...
...
actionpack/test/abstract_controller/helper_test.rb
浏览文件 @
030dfe3f
...
...
@@ -35,7 +35,7 @@ def index
class
TestHelpers
<
ActiveSupport
::
TestCase
def
test_helpers
result
=
MyHelpers1
.
process
(
:index
)
assert_equal
"Hello World : Included"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello World : Included"
,
result
.
response_
body
end
end
...
...
actionpack/test/abstract_controller/layouts_test.rb
浏览文件 @
030dfe3f
...
...
@@ -152,12 +152,12 @@ def index
class
TestBase
<
ActiveSupport
::
TestCase
test
"when no layout is specified, and no default is available, render without a layout"
do
result
=
Blank
.
process
(
:index
)
assert_equal
"Hello blank!"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello blank!"
,
result
.
response_
body
end
test
"when layout is specified as a string, render with that layout"
do
result
=
WithString
.
process
(
:index
)
assert_equal
"With String Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"With String Hello string!"
,
result
.
response_
body
end
test
"when layout is specified as a string, but the layout is missing, raise an exception"
do
...
...
@@ -166,22 +166,22 @@ class TestBase < ActiveSupport::TestCase
test
"when layout is specified as false, do not use a layout"
do
result
=
WithFalseLayout
.
process
(
:index
)
assert_equal
"Hello false!"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello false!"
,
result
.
response_
body
end
test
"when layout is specified as nil, do not use a layout"
do
result
=
WithNilLayout
.
process
(
:index
)
assert_equal
"Hello nil!"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello nil!"
,
result
.
response_
body
end
test
"when layout is specified as a symbol, call the requested method and use the layout returned"
do
result
=
WithSymbol
.
process
(
:index
)
assert_equal
"OMGHI2U Hello symbol!"
,
result
.
response_
obj
[
:body
]
assert_equal
"OMGHI2U Hello symbol!"
,
result
.
response_
body
end
test
"when layout is specified as a symbol and the method returns nil, don't use a layout"
do
result
=
WithSymbolReturningNil
.
process
(
:index
)
assert_equal
"Hello nilz!"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello nilz!"
,
result
.
response_
body
end
test
"when the layout is specified as a symbol and the method doesn't exist, raise an exception"
do
...
...
@@ -194,28 +194,28 @@ class TestBase < ActiveSupport::TestCase
test
"when a child controller does not have a layout, use the parent controller layout"
do
result
=
WithStringChild
.
process
(
:index
)
assert_equal
"With String Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"With String Hello string!"
,
result
.
response_
body
end
test
"when a child controller has specified a layout, use that layout and not the parent controller layout"
do
result
=
WithStringOverriddenChild
.
process
(
:index
)
assert_equal
"With Override Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"With Override Hello string!"
,
result
.
response_
body
end
test
"when a child controller has an implied layout, use that layout and not the parent controller layout"
do
result
=
WithStringImpliedChild
.
process
(
:index
)
assert_equal
"With Implied Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"With Implied Hello string!"
,
result
.
response_
body
end
test
"when a child controller specifies layout nil, do not use the parent layout"
do
result
=
WithNilChild
.
process
(
:index
)
assert_equal
"Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"Hello string!"
,
result
.
response_
body
end
test
"when a grandchild has no layout specified, the child has an implied layout, and the "
\
"parent has specified a layout, use the child controller layout"
do
result
=
WithChildOfImplied
.
process
(
:index
)
assert_equal
"With Implied Hello string!"
,
result
.
response_
obj
[
:body
]
assert_equal
"With Implied Hello string!"
,
result
.
response_
body
end
test
"raises an exception when specifying layout true"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录