Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d4a817c0
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 搜索 >>
提交
d4a817c0
编写于
2月 02, 2009
作者:
Y
Yehuda Katz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make tests pass
上级
ff684300
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
2 addition
and
123 deletion
+2
-123
activesupport/test/new_callbacks_test.rb
activesupport/test/new_callbacks_test.rb
+0
-121
railties/test/error_page_test.rb
railties/test/error_page_test.rb
+1
-1
railties/test/rails_info_controller_test.rb
railties/test/rails_info_controller_test.rb
+1
-1
未找到文件。
activesupport/test/new_callbacks_test.rb
已删除
100644 → 0
浏览文件 @
ff684300
# require 'abstract_unit'
require
'test/unit'
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/../lib"
require
'active_support'
class
Record
include
ActiveSupport
::
Callbacks
define_callbacks
:save
end
class
AroundPerson
<
Record
attr_reader
:history
save_callback
:before
,
:nope
,
:if
=>
:no
save_callback
:before
,
:nope
,
:unless
=>
:yes
save_callback
:after
,
:tweedle
save_callback
:before
,
"tweedle_dee"
save_callback
:before
,
proc
{
|
m
|
m
.
history
<<
"yup"
}
save_callback
:before
,
:nope
,
:if
=>
proc
{
false
}
save_callback
:before
,
:nope
,
:unless
=>
proc
{
true
}
save_callback
:before
,
:yup
,
:if
=>
proc
{
true
}
save_callback
:before
,
:yup
,
:unless
=>
proc
{
false
}
save_callback
:around
,
:tweedle_dum
save_callback
:around
,
:w0tyes
,
:if
=>
:yes
save_callback
:around
,
:w0tno
,
:if
=>
:no
save_callback
:around
,
:tweedle_deedle
def
no
;
false
;
end
def
yes
;
true
;
end
def
nope
@history
<<
"boom"
end
def
yup
@history
<<
"yup"
end
def
w0tyes
@history
<<
"w0tyes before"
yield
@history
<<
"w0tyes after"
end
def
w0tno
@history
<<
"boom"
yield
end
def
tweedle_dee
@history
<<
"tweedle dee"
end
def
tweedle_dum
@history
<<
"tweedle dum pre"
yield
@history
<<
"tweedle dum post"
end
def
tweedle
@history
<<
"tweedle"
end
def
tweedle_deedle
@history
<<
"tweedle deedle pre"
yield
@history
<<
"tweedle deedle post"
end
def
initialize
@history
=
[]
end
def
save
_run_save_callbacks
do
@history
<<
"running"
end
end
end
class
Foo
include
ActiveSupport
::
Callbacks
define_callbacks
:save
end
class
Bar
<
Foo
save_callback
(
:before
)
{
|
s
|
puts
"Before"
}
end
class
Baz
<
Bar
save_callback
(
:after
)
{
|
s
|
puts
"After"
}
end
class
Bat
<
Baz
def
inside
_run_save_callbacks
do
puts
"Inside"
end
end
end
Bat
.
new
.
inside
# class AroundCallbacksTest < Test::Unit::TestCase
# def test_save_around
# around = AroundPerson.new
# around.save
# assert_equal [
# "tweedle dee",
# "yup", "yup", "yup",
# "tweedle dum pre",
# "w0tyes before",
# "tweedle deedle pre",
# "running",
# "tweedle deedle post",
# "w0tyes after",
# "tweedle dum post",
# "tweedle"
# ], around.history
# end
# end
\ No newline at end of file
railties/test/error_page_test.rb
浏览文件 @
d4a817c0
require
'abstract_unit'
require
'action_controller'
require
'action_controller/test_case'
require
'action_controller/test
ing/test
_case'
RAILS_ENV
=
"test"
CURRENT_DIR
=
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
...
...
railties/test/rails_info_controller_test.rb
浏览文件 @
d4a817c0
require
'abstract_unit'
require
'action_controller'
require
'action_controller/test
_
process'
require
'action_controller/test
ing/
process'
module
Rails
;
end
require
'rails/info'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录