Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6e0254e8
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,发现更多精彩内容 >>
提交
6e0254e8
编写于
10月 03, 2015
作者:
W
Wojciech Wnętrzak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed serializing `:at` option for `assert_enqueued_with` and `assert_performed_with`
上级
55ac94ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
8 deletion
+32
-8
activejob/CHANGELOG.md
activejob/CHANGELOG.md
+5
-0
activejob/lib/active_job/test_helper.rb
activejob/lib/active_job/test_helper.rb
+11
-4
activejob/test/cases/test_helper_test.rb
activejob/test/cases/test_helper_test.rb
+16
-4
未找到文件。
activejob/CHANGELOG.md
浏览文件 @
6e0254e8
*
Fixed serializing
`:at`
option for
`assert_enqueued_with`
and
`assert_performed_with`
*Wojciech Wnętrzak*
*
Support passing array to
`assert_enqueued_jobs`
in
`:only`
option.
*Wojciech Wnętrzak*
...
...
activejob/lib/active_job/test_helper.rb
浏览文件 @
6e0254e8
...
...
@@ -226,6 +226,10 @@ def assert_no_performed_jobs(only: nil, &block)
# assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do
# MyJob.perform_later(1,2,3)
# end
#
# assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon) do
# MyJob.set(wait_until: Date.tomorrow.noon).perform_later
# end
# end
def
assert_enqueued_with
(
args
=
{},
&
_block
)
original_enqueued_jobs
=
enqueued_jobs
.
dup
...
...
@@ -248,6 +252,10 @@ def assert_enqueued_with(args = {}, &_block)
# assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') do
# MyJob.perform_later(1,2,3)
# end
#
# assert_performed_with(job: MyJob, at: Date.tomorrow.noon) do
# MyJob.set(wait_until: Date.tomorrow.noon).perform_later
# end
# end
def
assert_performed_with
(
args
=
{},
&
_block
)
original_performed_jobs
=
performed_jobs
.
dup
...
...
@@ -307,11 +315,10 @@ def enqueued_jobs_size(only: nil) # :nodoc:
end
def
serialize_args_for_assertion
(
args
)
# :nodoc:
serialized_args
=
args
.
dup
if
job_args
=
serialized_args
.
delete
(
:args
)
serialized_args
[
:a
rgs
]
=
ActiveJob
::
Arguments
.
serialize
(
job_args
)
args
.
dup
.
tap
do
|
serialized_args
|
serialized_args
[
:args
]
=
ActiveJob
::
Arguments
.
serialize
(
serialized_args
[
:args
])
if
serialized_args
[
:args
]
serialized_args
[
:a
t
]
=
serialized_args
[
:at
].
to_f
if
serialized_args
[
:at
]
end
serialized_args
end
def
instantiate_job
(
payload
)
# :nodoc:
...
...
activejob/test/cases/test_helper_test.rb
浏览文件 @
6e0254e8
...
...
@@ -218,6 +218,12 @@ def test_assert_enqueued_job_args
end
end
def
test_assert_enqueued_job_with_at_option
assert_enqueued_with
(
job:
HelloJob
,
at:
Date
.
tomorrow
.
noon
)
do
HelloJob
.
set
(
wait_until:
Date
.
tomorrow
.
noon
).
perform_later
end
end
def
test_assert_enqueued_job_with_global_id_args
ricardo
=
Person
.
new
(
9
)
assert_enqueued_with
(
job:
HelloJob
,
args:
[
ricardo
])
do
...
...
@@ -439,18 +445,24 @@ def test_assert_performed_job_returns
def
test_assert_performed_job_failure
assert_raise
ActiveSupport
::
TestCase
::
Assertion
do
assert_performed_with
(
job:
LoggingJob
,
at:
Date
.
tomorrow
.
noon
,
queue:
'default'
)
do
NestedJob
.
set
(
wait_until:
Date
.
tomorrow
.
noon
)
.
perform_later
assert_performed_with
(
job:
LoggingJob
)
do
HelloJob
.
perform_later
end
end
assert_raise
ActiveSupport
::
TestCase
::
Assertion
do
assert_performed_with
(
job:
NestedJob
,
at:
Date
.
tomorrow
.
noon
,
queue:
'low'
)
do
NestedJob
.
set
(
queue:
'low'
,
wait_until:
Date
.
tomorrow
.
noon
).
perform_later
assert_performed_with
(
job:
HelloJob
,
queue:
'low'
)
do
HelloJob
.
set
(
queue:
'important'
).
perform_later
end
end
end
def
test_assert_performed_job_with_at_option
assert_performed_with
(
job:
HelloJob
,
at:
Date
.
tomorrow
.
noon
)
do
HelloJob
.
set
(
wait_until:
Date
.
tomorrow
.
noon
).
perform_later
end
end
def
test_assert_performed_job_with_global_id_args
ricardo
=
Person
.
new
(
9
)
assert_performed_with
(
job:
HelloJob
,
args:
[
ricardo
])
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录