Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8a4e77b4
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 搜索 >>
提交
8a4e77b4
编写于
4月 27, 2009
作者:
Y
Yehuda Katz + Carl Lerche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OMG, a lot of work
上级
34509777
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
210 addition
and
86 deletion
+210
-86
actionpack/Rakefile
actionpack/Rakefile
+9
-2
actionpack/lib/action_controller/abstract/layouts.rb
actionpack/lib/action_controller/abstract/layouts.rb
+3
-2
actionpack/lib/action_controller/abstract/renderer.rb
actionpack/lib/action_controller/abstract/renderer.rb
+2
-0
actionpack/lib/action_controller/dispatch/dispatcher.rb
actionpack/lib/action_controller/dispatch/dispatcher.rb
+1
-1
actionpack/lib/action_controller/dispatch/middlewares.rb
actionpack/lib/action_controller/dispatch/middlewares.rb
+1
-1
actionpack/lib/action_controller/new_base.rb
actionpack/lib/action_controller/new_base.rb
+6
-5
actionpack/lib/action_controller/new_base/base.rb
actionpack/lib/action_controller/new_base/base.rb
+2
-0
actionpack/lib/action_controller/new_base/compatibility.rb
actionpack/lib/action_controller/new_base/compatibility.rb
+12
-0
actionpack/test/abstract_controller/abstract_controller_test.rb
...pack/test/abstract_controller/abstract_controller_test.rb
+9
-13
actionpack/test/abstract_controller/layouts_test.rb
actionpack/test/abstract_controller/layouts_test.rb
+1
-1
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+3
-0
actionpack/test/lib/fixture_template.rb
actionpack/test/lib/fixture_template.rb
+92
-23
actionpack/test/new_base/base_test.rb
actionpack/test/new_base/base_test.rb
+4
-4
actionpack/test/new_base/render_action_test.rb
actionpack/test/new_base/render_action_test.rb
+4
-4
actionpack/test/new_base/render_implicit_action_test.rb
actionpack/test/new_base/render_implicit_action_test.rb
+21
-9
actionpack/test/new_base/render_layout_test.rb
actionpack/test/new_base/render_layout_test.rb
+2
-2
actionpack/test/new_base/render_template_test.rb
actionpack/test/new_base/render_template_test.rb
+23
-16
actionpack/test/new_base/render_text_test.rb
actionpack/test/new_base/render_text_test.rb
+2
-2
actionpack/test/new_base/test_helper.rb
actionpack/test/new_base/test_helper.rb
+13
-1
未找到文件。
actionpack/Rakefile
浏览文件 @
8a4e77b4
...
...
@@ -23,14 +23,14 @@ task :default => [ :test ]
# Run the unit tests
desc
"Run all unit tests"
task
:test
=>
[
:test_action_pack
,
:test_active_record_integration
]
task
:test
=>
[
:test_action_pack
,
:test_active_record_integration
,
:test_new_base
]
Rake
::
TestTask
.
new
(
:test_action_pack
)
do
|
t
|
t
.
libs
<<
"test"
# make sure we include the tests in alphabetical order as on some systems
# this will not happen automatically and the tests (as a whole) will error
t
.
test_files
=
Dir
.
glob
(
"test/
[cdft]*
/**/*_test.rb"
).
sort
t
.
test_files
=
Dir
.
glob
(
"test/
{controller,dispatch,template}
/**/*_test.rb"
).
sort
t
.
verbose
=
true
#t.warning = true
...
...
@@ -43,6 +43,13 @@ Rake::TestTask.new(:test_active_record_integration) do |t|
t
.
verbose
=
true
end
desc
'New Controller Tests'
Rake
::
TestTask
.
new
(
:test_new_base
)
do
|
t
|
t
.
libs
<<
"test"
t
.
test_files
=
Dir
.
glob
(
"test/{abstract_controller,new_base}/*_test.rb"
)
t
.
verbose
=
true
end
# Genereate the RDoc documentation
...
...
actionpack/lib/action_controller/abstract/layouts.rb
浏览文件 @
8a4e77b4
...
...
@@ -50,6 +50,7 @@ def _layout
end
def
_render_template
(
template
,
options
)
# layout = options[:_layout].is_a?(ActionView::Template) ? options[:_layout] : _layout_for_name(options[:_layout])
_action_view
.
_render_template_with_layout
(
template
,
options
[
:_layout
])
end
...
...
@@ -67,10 +68,10 @@ def _layout_for_name(name)
def
_default_layout
(
require_layout
=
false
)
if
require_layout
&&
!
_layout
raise
ArgumentError
,
raise
ArgumentError
,
"There was no default layout for
#{
self
.
class
}
in
#{
view_paths
.
inspect
}
"
end
begin
layout
=
_layout_for_name
(
_layout
)
rescue
NameError
=>
e
...
...
actionpack/lib/action_controller/abstract/renderer.rb
浏览文件 @
8a4e77b4
...
...
@@ -27,9 +27,11 @@ def render(options = {})
#
# :api: plugin
def
render_to_body
(
options
=
{})
options
=
{
:_template_name
=>
options
}
if
options
.
is_a?
(
String
)
name
=
options
[
:_template_name
]
||
action_name
template
=
options
[
:_template
]
||
view_paths
.
find_by_parts
(
name
.
to_s
,
{
:formats
=>
formats
},
options
[
:_prefix
])
_render_template
(
template
,
options
)
end
...
...
actionpack/lib/action_controller/dispatch/dispatcher.rb
浏览文件 @
8a4e77b4
...
...
@@ -79,7 +79,7 @@ def _call(env)
run_callbacks
:before_dispatch
Routing
::
Routes
.
call
(
env
)
rescue
Exception
=>
exception
if
controller
||=
(
::
ApplicationController
rescue
Base
)
if
!
env
[
"rack.test"
]
&&
controller
||=
(
::
ApplicationController
rescue
Base
)
controller
.
call_with_exception
(
env
,
exception
).
to_a
else
raise
exception
...
...
actionpack/lib/action_controller/dispatch/middlewares.rb
浏览文件 @
8a4e77b4
...
...
@@ -9,4 +9,4 @@
use
"ActionDispatch::ParamsParser"
use
"Rack::MethodOverride"
use
"Rack::Head"
use
"Rack::Head"
\ No newline at end of file
actionpack/lib/action_controller/new_base.rb
浏览文件 @
8a4e77b4
module
ActionController
autoload
:AbstractBase
,
"action_controller/new_base/base"
autoload
:HideActions
,
"action_controller/new_base/hide_actions"
autoload
:Layouts
,
"action_controller/new_base/layouts"
autoload
:Renderer
,
"action_controller/new_base/renderer"
autoload
:UrlFor
,
"action_controller/new_base/url_for"
autoload
:AbstractBase
,
"action_controller/new_base/base"
autoload
:HideActions
,
"action_controller/new_base/hide_actions"
autoload
:Layouts
,
"action_controller/new_base/layouts"
autoload
:Rails2Compatibility
,
"action_controller/new_base/compatibility"
autoload
:Renderer
,
"action_controller/new_base/renderer"
autoload
:UrlFor
,
"action_controller/new_base/url_for"
end
\ No newline at end of file
actionpack/lib/action_controller/new_base/base.rb
浏览文件 @
8a4e77b4
...
...
@@ -50,6 +50,8 @@ def call(env)
@_request
=
ActionDispatch
::
Request
.
new
(
env
)
@_response
=
ActionDispatch
::
Response
.
new
process
(
@_request
.
parameters
[
:action
])
@_response
.
prepare!
self
end
# :api: private
...
...
actionpack/lib/action_controller/new_base/compatibility.rb
0 → 100644
浏览文件 @
8a4e77b4
module
ActionController
module
Rails2Compatibility
def
render_to_body
(
options
)
if
options
.
is_a?
(
Hash
)
&&
options
.
key?
(
:template
)
options
[
:template
].
sub!
(
/^\//
,
''
)
end
super
end
end
end
\ No newline at end of file
actionpack/test/abstract_controller/abstract_controller_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -58,11 +58,11 @@ def naked_render
end
def
rendering_to_body
render_to_body
"naked_render.erb"
self
.
response_body
=
render_to_body
:_template_name
=>
"naked_render.erb"
end
def
rendering_to_string
render_to_string
"naked_render.erb"
self
.
response_body
=
render_to_string
:_template_name
=>
"naked_render.erb"
end
end
...
...
@@ -136,6 +136,11 @@ class TestPrefixedViews < ActiveSupport::TestCase
class
WithLayouts
<
PrefixedViews
use
Layouts
def
self
.
inherited
(
klass
)
klass
.
_write_layout_method
super
end
private
def
self
.
layout
(
formats
)
begin
...
...
@@ -147,13 +152,9 @@ def self.layout(formats)
end
end
end
def
_layout
self
.
class
.
layout
(
formats
)
end
def
render_to_body
(
options
=
{})
options
[
:_layout
]
=
options
[
:layout
]
||
_layout
options
[
:_layout
]
=
options
[
:layout
]
||
_
default_
layout
super
end
end
...
...
@@ -175,11 +176,6 @@ class TestLayouts < ActiveSupport::TestCase
result
=
Me4
.
process
(
:index
)
assert_equal
"Me4 Enter : Hello from me4/index.erb : Exit"
,
result
.
response_obj
[
:body
]
end
test
"it can fall back to the application layout"
do
result
=
Me5
.
process
(
:index
)
assert_equal
"Application Enter : Hello from me5/index.erb : Exit"
,
result
.
response_obj
[
:body
]
end
end
# respond_to_action?(action_name)
...
...
actionpack/test/abstract_controller/layouts_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -8,7 +8,7 @@ class Base < AbstractController::Base
use
AbstractController
::
Renderer
use
AbstractController
::
Layouts
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/hello.erb"
=>
"With String <%= yield %>"
,
"layouts/hello_override.erb"
=>
"With Override <%= yield %>"
,
"layouts/abstract_controller_tests/layouts/with_string_implied_child.erb"
=>
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -755,6 +755,7 @@ def setup
@request
.
host
=
"www.nextangle.com"
end
# :ported:
def
test_simple_show
get
:hello_world
assert_response
200
...
...
@@ -763,11 +764,13 @@ def test_simple_show
assert_equal
"<html>Hello world!</html>"
,
@response
.
body
end
# :ported:
def
test_renders_default_template_for_missing_action
get
:'hyphen-ated'
assert_template
'test/hyphen-ated'
end
# :ported:
def
test_render
get
:render_hello_world
assert_template
"test/hello_world"
...
...
actionpack/test/lib/fixture_template.rb
浏览文件 @
8a4e77b4
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
)
class
Template
class
FixturePath
<
Path
def
initialize
(
hash
=
{},
options
=
{})
super
(
options
)
@hash
=
hash
end
def
find_templates
(
name
,
details
,
prefix
,
partial
)
if
regexp
=
details_to_regexp
(
name
,
details
,
prefix
,
partial
)
cached
(
regexp
)
do
templates
=
[]
@hash
.
select
{
|
k
,
v
|
k
=~
regexp
}.
each
do
|
path
,
source
|
templates
<<
Template
.
new
(
source
,
path
,
*
path_to_details
(
path
))
end
templates
end
super
(
"fixtures://root"
)
end
def
find_template
(
path
)
@hash
[
path
]
end
end
def
initialize
(
body
,
*
args
)
@body
=
body
super
(
*
args
)
private
def
formats_regexp
@formats_regexp
||=
begin
formats
=
Mime
::
SET
.
map
{
|
m
|
m
.
symbol
}
'(?:'
+
formats
.
map
{
|
l
|
"
\\
.
#{
Regexp
.
escape
(
l
.
to_s
)
}
"
}.
join
(
'|'
)
+
')?'
end
end
def
source
@body
def
handler_regexp
e
=
TemplateHandlers
.
extensions
.
map
{
|
h
|
"
\\
.
#{
Regexp
.
escape
(
h
.
to_s
)
}
"
}.
join
(
"|"
)
"(?:
#{
e
}
)?"
end
private
def
find_full_path
(
path
,
load_paths
)
return
'/'
,
path
def
details_to_regexp
(
name
,
details
,
prefix
,
partial
)
path
=
""
path
<<
"
#{
prefix
}
/"
unless
prefix
.
empty?
path
<<
(
partial
?
"_
#{
name
}
"
:
name
)
extensions
=
""
[
:locales
,
:formats
].
each
do
|
k
|
extensions
<<
if
exts
=
details
[
k
]
'(?:'
+
exts
.
map
{
|
e
|
"
\\
.
#{
Regexp
.
escape
(
e
.
to_s
)
}
"
}.
join
(
'|'
)
+
')?'
else
k
==
:formats
?
formats_regexp
:
''
end
end
%r'
#{
Regexp
.
escape
(
path
)
}#{
extensions
}#{
handler_regexp
}
'
end
# TODO: fix me
# :api: plugin
def
path_to_details
(
path
)
# [:erb, :format => :html, :locale => :en, :partial => true/false]
if
m
=
path
.
match
(
%r'(_)?[
\w
-]+(
\.
[
\w
-]+)*
\.
(
\w
+)$'
)
partial
=
m
[
1
]
==
'_'
details
=
(
m
[
2
]
||
""
).
split
(
'.'
).
reject
{
|
e
|
e
.
empty?
}
handler
=
Template
.
handler_class_for_extension
(
m
[
3
])
format
=
Mime
[
details
.
last
]
&&
details
.
pop
.
to_sym
locale
=
details
.
last
&&
details
.
pop
.
to_sym
return
handler
,
:format
=>
format
,
:locale
=>
locale
,
:partial
=>
partial
end
end
end
# 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("fixtures://root")
# 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
end
\ No newline at end of file
actionpack/test/new_base/base_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -34,11 +34,11 @@ class TestSimpleDispatch < SimpleRouteCase
end
test
"sets the content type"
do
assert_content_type
Mime
::
HTML
assert_content_type
"text/html; charset=utf-8"
end
test
"sets the content length"
do
assert_header
"Content-Length"
,
7
assert_header
"Content-Length"
,
"7"
end
end
...
...
@@ -52,7 +52,7 @@ class TestDirectResponseMod < SimpleRouteCase
end
test
"setting the body manually sets the content length"
do
assert_header
"Content-Length"
,
7
assert_header
"Content-Length"
,
"7"
end
end
...
...
@@ -65,7 +65,7 @@ class TestDirectResponseModTwice < SimpleRouteCase
end
test
"updating the response body updates the content length"
do
assert_header
"Content-Length"
,
8
assert_header
"Content-Length"
,
"8"
end
end
end
...
...
actionpack/test/new_base/render_action_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -5,7 +5,7 @@ module RenderAction
# This has no layout and it works
class
BasicController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"render_action/basic/hello_world.html.erb"
=>
"Hello world!"
)]
...
...
@@ -129,7 +129,7 @@ module RenderActionWithApplicationLayout
class
BasicController
<
::
ApplicationController
# Set the view path to an application view structure with layouts
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"render_action_with_application_layout/basic/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
,
"layouts/greetings.html.erb"
=>
"Greetings <%= yield %> Bai"
...
...
@@ -204,7 +204,7 @@ class TestCustomLayout < SimpleRouteCase
module
RenderActionWithControllerLayout
class
BasicController
<
ActionController
::
Base2
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"render_action_with_controller_layout/basic/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/render_action_with_controller_layout/basic.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
)]
...
...
@@ -267,7 +267,7 @@ class TestLayoutNil < SimpleRouteCase
module
RenderActionWithBothLayouts
class
BasicController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
({
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
({
"render_action_with_both_layouts/basic/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
,
"layouts/render_action_with_both_layouts/basic.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
...
...
actionpack/test/new_base/render_implicit_action_test.rb
浏览文件 @
8a4e77b4
require
File
.
join
(
File
.
expand_path
(
File
.
dirname
(
__FILE__
)),
"test_helper"
)
module
HappyPath
class
RenderImplicitActionController
<
ActionController
::
Base2
# No actions yet, they are implicit
module
RenderImplicitAction
class
SimpleController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"render_implicit_action/simple/hello_world.html.erb"
=>
"Hello world!"
,
"render_implicit_action/simple/hyphen-ated.html.erb"
=>
"Hello hyphen-ated"
)]
def
hello_world
()
end
end
class
TestRendersActionImplicitly
<
SimpleRouteCase
test
"renders action implicitly"
do
assert
true
end
class
TestImplicitRender
<
SimpleRouteCase
describe
"render a simple action with new explicit call to render"
get
"/render_implicit_action/simple/hello_world"
assert_body
"Hello world!"
assert_status
200
end
class
TestImplicitWithSpecialCharactersRender
<
SimpleRouteCase
describe
"render an action with a missing method and has special characters"
get
"/render_implicit_action/simple/hyphen-ated"
assert_body
"Hello hyphen-ated!"
assert_status
200
end
end
\ No newline at end of file
actionpack/test/new_base/render_layout_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -3,7 +3,7 @@
module
ControllerLayouts
class
ImplicitController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/application.html.erb"
=>
"OMG <%= yield %> KTHXBAI"
,
"basic.html.erb"
=>
"Hello world!"
)]
...
...
@@ -23,7 +23,7 @@ class TestImplicitLayout < SimpleRouteCase
class
ImplicitNameController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/controller_layouts/implicit_name.html.erb"
=>
"OMGIMPLICIT <%= yield %> KTHXBAI"
,
"basic.html.erb"
=>
"Hello world!"
)]
...
...
actionpack/test/new_base/render_template_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -4,7 +4,7 @@ module HappyPath
class
RenderTemplateWithoutLayoutController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
)]
...
...
@@ -13,10 +13,6 @@ def render_hello_world
render
:template
=>
"test/basic"
end
def
render_hello_world_with_forward_slash
render
:template
=>
"/test/basic"
end
def
render_template_in_top_directory
render
:template
=>
'shared'
end
...
...
@@ -34,14 +30,6 @@ class TestTemplateRenderWithoutLayout < SimpleRouteCase
assert_status
200
end
class
TestTemplateRenderWithForwardSlash
<
SimpleRouteCase
describe
"rendering a normal template with full path starting with a leading slash"
get
"/happy_path/render_template_without_layout/render_hello_world_with_forward_slash"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
class
TestTemplateRenderInTopDirectory
<
SimpleRouteCase
describe
"rendering a template not in a subdirectory"
...
...
@@ -60,7 +48,7 @@ class TestTemplateRenderInTopDirectoryWithSlash < SimpleRouteCase
class
RenderTemplateWithLayoutController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
,
"layouts/application.html.erb"
=>
"<%= yield %>, I'm here!"
,
...
...
@@ -127,7 +115,26 @@ class TestTemplateRenderWithCustomLayout < SimpleRouteCase
assert_body
"Hello from basic.html.erb, I wish thee well."
assert_status
200
end
end
module
Compatibility
class
RenderTemplateWithoutLayoutController
<
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
render
:template
=>
"/test/basic"
end
end
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"
assert_body
"Hello from basic.html.erb"
assert_status
200
end
end
\ No newline at end of file
actionpack/test/new_base/render_text_test.rb
浏览文件 @
8a4e77b4
...
...
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base2
module
HappyPath
class
RenderTextWithoutLayoutsController
<
ActionController
::
Base2
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
]
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
]
def
render_hello_world
render
:text
=>
"hello david"
...
...
@@ -14,7 +14,7 @@ def render_hello_world
end
class
RenderTextWithLayoutsController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Fixture
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/application.html.erb"
=>
"<%= yield %>, I'm here!"
,
"layouts/greetings.html.erb"
=>
"<%= yield %>, I wish thee well."
)]
...
...
actionpack/test/new_base/test_helper.rb
浏览文件 @
8a4e77b4
...
...
@@ -24,6 +24,14 @@
require
'rubygems'
require
'rack/test'
module
Rails
def
self
.
env
x
=
Object
.
new
def
x
.
test?
()
true
end
x
end
end
module
ActionController
class
Base2
<
AbstractBase
use
AbstractController
::
Callbacks
...
...
@@ -54,6 +62,10 @@ def self.app_loaded!
CORE_METHODS
=
self
.
public_instance_methods
end
class
CompatibleBase2
<
Base2
use
ActionController
::
Rails2Compatibility
end
end
# Temporary base class
...
...
@@ -91,7 +103,7 @@ def self.get(url)
end
def
assert_body
(
body
)
assert_equal
[
body
]
,
last_response
.
body
assert_equal
body
,
last_response
.
body
end
def
self
.
assert_body
(
body
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录