Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5988b87c
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,发现更多精彩内容 >>
提交
5988b87c
编写于
10月 15, 2009
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added parent_of? method to help tracing events.
上级
11f9f556
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
3 deletion
+24
-3
activesupport/lib/active_support/orchestra.rb
activesupport/lib/active_support/orchestra.rb
+5
-0
activesupport/test/orchestra_test.rb
activesupport/test/orchestra_test.rb
+19
-3
未找到文件。
activesupport/lib/active_support/orchestra.rb
浏览文件 @
5988b87c
...
...
@@ -112,6 +112,11 @@ def initialize(name, payload)
@result
=
@payload
.
delete
(
:result
)
@duration
=
@payload
.
delete
(
:duration
)
end
def
parent_of?
(
event
)
start
=
(
self
.
time
-
event
.
time
)
*
1000
start
<=
0
&&
(
start
+
self
.
duration
>=
event
.
duration
)
end
end
# This is a default queue implementation that ships with Orchestra. It
...
...
activesupport/test/orchestra_test.rb
浏览文件 @
5988b87c
...
...
@@ -9,20 +9,36 @@ def clear
class
OrchestraEventTest
<
Test
::
Unit
::
TestCase
def
test_events_are_initialized_with_name_and_payload
event
=
ActiveSupport
::
Orchestra
::
Event
.
new
(
:foo
,
:payload
=>
:bar
)
event
=
event
(
:foo
,
:payload
=>
:bar
)
assert_equal
:foo
,
event
.
name
assert_equal
Hash
[
:payload
=>
:bar
],
event
.
payload
end
def
test_events_consumes_information_given_as_payload
event
=
ActiveSupport
::
Orchestra
::
Event
.
new
(
:foo
,
:time
=>
(
time
=
Time
.
now
),
:result
=>
1
,
:duration
=>
10
)
event
=
event
(
:foo
,
:time
=>
(
time
=
Time
.
now
),
:result
=>
1
,
:duration
=>
10
)
assert_equal
Hash
.
new
,
event
.
payload
assert_equal
time
,
event
.
time
assert_equal
1
,
event
.
result
assert_equal
10
,
event
.
duration
end
def
test_event_is_parent_based_on_time_frame
parent
=
event
(
:foo
,
:time
=>
Time
.
utc
(
2009
),
:duration
=>
10000
)
child
=
event
(
:foo
,
:time
=>
Time
.
utc
(
2009
,
01
,
01
,
0
,
0
,
1
),
:duration
=>
1000
)
not_child
=
event
(
:foo
,
:time
=>
Time
.
utc
(
2009
,
01
,
01
,
0
,
0
,
1
),
:duration
=>
10000
)
assert
parent
.
parent_of?
(
child
)
assert
!
child
.
parent_of?
(
parent
)
assert
!
parent
.
parent_of?
(
not_child
)
assert
!
not_child
.
parent_of?
(
parent
)
end
protected
def
event
(
*
args
)
ActiveSupport
::
Orchestra
::
Event
.
new
(
*
args
)
end
end
class
OrchestraMainTest
<
Test
::
Unit
::
TestCase
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录