Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d76d66fb
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,发现更多精彩内容 >>
未验证
提交
d76d66fb
编写于
10月 24, 2018
作者:
R
Rafael França
提交者:
GitHub
10月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34204 from XrXr/aj-test-helper-args
Include deserialized arguments in jobs returned by AJ test helpers
上级
d3e64659
3ebc2290
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
15 deletion
+20
-15
activejob/CHANGELOG.md
activejob/CHANGELOG.md
+5
-0
activejob/lib/active_job/test_helper.rb
activejob/lib/active_job/test_helper.rb
+3
-3
activejob/test/cases/test_helper_test.rb
activejob/test/cases/test_helper_test.rb
+12
-12
未找到文件。
activejob/CHANGELOG.md
浏览文件 @
d76d66fb
*
Include deserialized arguments in job instances returned from
`assert_enqueued_with`
and
`assert_performed_with`
*Alan Wu*
*
Allow
`assert_enqueued_with`
/
`assert_performed_with`
methods to accept
a proc for the
`args`
argument. This is useful to check if only a subset of arguments
matches your expectations.
...
...
activejob/lib/active_job/test_helper.rb
浏览文件 @
d76d66fb
...
...
@@ -594,8 +594,7 @@ def performed_jobs_with(only: nil, except: nil, queue: nil, &block)
def
flush_enqueued_jobs
(
only:
nil
,
except:
nil
,
queue:
nil
)
enqueued_jobs_with
(
only:
only
,
except:
except
,
queue:
queue
)
do
|
payload
|
args
=
ActiveJob
::
Arguments
.
deserialize
(
payload
[
:args
])
instantiate_job
(
payload
.
merge
(
args:
args
)).
perform_now
instantiate_job
(
payload
).
perform_now
queue_adapter
.
performed_jobs
<<
payload
end
end
...
...
@@ -613,7 +612,8 @@ def deserialize_args_for_assertion(job)
end
def
instantiate_job
(
payload
)
job
=
payload
[
:job
].
new
(
*
payload
[
:args
])
args
=
ActiveJob
::
Arguments
.
deserialize
(
payload
[
:args
])
job
=
payload
[
:job
].
new
(
*
args
)
job
.
scheduled_at
=
Time
.
at
(
payload
[
:at
])
if
payload
.
key?
(
:at
)
job
.
queue_name
=
payload
[
:queue
]
job
...
...
activejob/test/cases/test_helper_test.rb
浏览文件 @
d76d66fb
...
...
@@ -476,23 +476,23 @@ def test_assert_enqueued_with_with_no_block
def
test_assert_enqueued_with_returns
job
=
assert_enqueued_with
(
job:
LoggingJob
)
do
LoggingJob
.
set
(
wait_until:
5
.
minutes
.
from_now
).
perform_later
(
1
,
2
,
3
)
LoggingJob
.
set
(
wait_until:
5
.
minutes
.
from_now
).
perform_later
(
1
,
2
,
3
,
keyword:
true
)
end
assert_instance_of
LoggingJob
,
job
assert_in_delta
5
.
minutes
.
from_now
,
job
.
scheduled_at
,
1
assert_equal
"default"
,
job
.
queue_name
assert_equal
[
1
,
2
,
3
],
job
.
arguments
assert_equal
[
1
,
2
,
3
,
{
keyword:
true
}
],
job
.
arguments
end
def
test_assert_enqueued_with_with_no_block_returns
LoggingJob
.
set
(
wait_until:
5
.
minutes
.
from_now
).
perform_later
(
1
,
2
,
3
)
LoggingJob
.
set
(
wait_until:
5
.
minutes
.
from_now
).
perform_later
(
1
,
2
,
3
,
keyword:
true
)
job
=
assert_enqueued_with
(
job:
LoggingJob
)
assert_instance_of
LoggingJob
,
job
assert_in_delta
5
.
minutes
.
from_now
,
job
.
scheduled_at
,
1
assert_equal
"default"
,
job
.
queue_name
assert_equal
[
1
,
2
,
3
],
job
.
arguments
assert_equal
[
1
,
2
,
3
,
{
keyword:
true
}
],
job
.
arguments
end
def
test_assert_enqueued_with_failure
...
...
@@ -1515,26 +1515,26 @@ def test_assert_performed_with_without_block
end
def
test_assert_performed_with_returns
job
=
assert_performed_with
(
job:
Nested
Job
,
queue:
"default"
)
do
NestedJob
.
perform_later
job
=
assert_performed_with
(
job:
Logging
Job
,
queue:
"default"
)
do
LoggingJob
.
perform_later
(
keyword: :sym
)
end
assert_instance_of
Nested
Job
,
job
assert_instance_of
Logging
Job
,
job
assert_nil
job
.
scheduled_at
assert_equal
[],
job
.
arguments
assert_equal
[
{
keyword: :sym
}
],
job
.
arguments
assert_equal
"default"
,
job
.
queue_name
end
def
test_assert_performed_with_without_block_returns
NestedJob
.
perform_later
LoggingJob
.
perform_later
(
keyword: :sym
)
perform_enqueued_jobs
job
=
assert_performed_with
(
job:
Nested
Job
,
queue:
"default"
)
job
=
assert_performed_with
(
job:
Logging
Job
,
queue:
"default"
)
assert_instance_of
Nested
Job
,
job
assert_instance_of
Logging
Job
,
job
assert_nil
job
.
scheduled_at
assert_equal
[],
job
.
arguments
assert_equal
[
{
keyword: :sym
}
],
job
.
arguments
assert_equal
"default"
,
job
.
queue_name
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录