Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
08cbf442
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,发现更多精彩内容 >>
未验证
提交
08cbf442
编写于
3月 11, 2020
作者:
R
Rafael França
提交者:
GitHub
3月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38686 from Edouard-chin/ec-job-test-adapter
AJ `perform_enqueued_jobs` shouldn't perform job retries:
上级
2f1fefe4
17e304de
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
9 deletion
+40
-9
activejob/CHANGELOG.md
activejob/CHANGELOG.md
+10
-0
activejob/lib/active_job/test_helper.rb
activejob/lib/active_job/test_helper.rb
+2
-2
activejob/test/cases/test_helper_test.rb
activejob/test/cases/test_helper_test.rb
+26
-5
activejob/test/jobs/raising_job.rb
activejob/test/jobs/raising_job.rb
+2
-2
未找到文件。
activejob/CHANGELOG.md
浏览文件 @
08cbf442
*
`ActiveJob::TestCase#perform_enqueued_jobs`
will no longer perform retries:
When calling `perform_enqueued_jobs` without a block, the adapter will
now perform jobs that are **already** in the queue. Jobs that will end up in
the queue afterwards won't be performed.
This change only affects `perform_enqueued_jobs` when no block is given.
*Edouard Chin*
*
Add queue name support to Que adapter
*Brad Nauta*, *Wojciech Wnętrzak*
...
...
activejob/lib/active_job/test_helper.rb
浏览文件 @
08cbf442
...
...
@@ -602,7 +602,7 @@ def clear_performed_jobs
def
jobs_with
(
jobs
,
only:
nil
,
except:
nil
,
queue:
nil
,
at:
nil
)
validate_option
(
only:
only
,
except:
except
)
jobs
.
count
do
|
job
|
jobs
.
dup
.
count
do
|
job
|
job_class
=
job
.
fetch
(
:job
)
if
only
...
...
@@ -641,8 +641,8 @@ def performed_jobs_with(only: nil, except: nil, queue: nil, &block)
def
flush_enqueued_jobs
(
only:
nil
,
except:
nil
,
queue:
nil
,
at:
nil
)
enqueued_jobs_with
(
only:
only
,
except:
except
,
queue:
queue
,
at:
at
)
do
|
payload
|
instantiate_job
(
payload
).
perform_now
queue_adapter
.
performed_jobs
<<
payload
instantiate_job
(
payload
).
perform_now
end
end
...
...
activejob/test/cases/test_helper_test.rb
浏览文件 @
08cbf442
...
...
@@ -909,6 +909,27 @@ def test_perform_enqueued_jobs_block_with_at_with_job_wait_in_future
assert_performed_jobs
0
end
def
test_perform_enqueued_jobs_properly_count_job_that_raises
RaisingJob
.
perform_later
(
"NotImplementedError"
)
assert_raises
(
NotImplementedError
)
do
perform_enqueued_jobs
(
only:
RaisingJob
)
end
assert_equal
(
1
,
performed_jobs
.
size
)
end
def
test_perform_enqueued_jobs_dont_perform_retries
RaisingJob
.
perform_later
assert_nothing_raised
do
perform_enqueued_jobs
(
only:
RaisingJob
)
end
assert_equal
(
1
,
performed_jobs
.
size
)
assert_equal
(
2
,
enqueued_jobs
.
size
)
end
def
test_assert_performed_jobs
assert_nothing_raised
do
assert_performed_jobs
1
do
...
...
@@ -1867,13 +1888,13 @@ def test_assert_performed_with_without_block_does_not_change_jobs_count
end
test
"TestAdapter respect max attempts"
do
RaisingJob
.
perform_later
assert_raises
(
RaisingJob
::
MyError
)
do
perform_enqueued_jobs
perform_enqueued_jobs
(
only:
RaisingJob
)
do
assert_raises
(
RaisingJob
::
MyError
)
do
RaisingJob
.
perform_later
end
end
assert_equal
2
,
queue_adapter
.
enqueu
ed_jobs
.
count
assert_equal
2
,
queue_adapter
.
perform
ed_jobs
.
count
end
end
...
...
activejob/test/jobs/raising_job.rb
浏览文件 @
08cbf442
...
...
@@ -5,7 +5,7 @@ class RaisingJob < ActiveJob::Base
retry_on
(
MyError
,
attempts:
2
)
def
perform
raise
MyError
def
perform
(
error
=
"RaisingJob::MyError"
)
raise
error
.
constantize
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录