activejob-retry 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +12 -6
- data/{Gemfile → Gemfile.activejob42} +1 -1
- data/Gemfile.activejob50 +22 -0
- data/README.md +7 -0
- data/lib/active_job/retry.rb +13 -5
- data/lib/active_job/retry/version.rb +1 -1
- data/spec/retry_spec.rb +2 -2
- metadata +4 -6
- data/Gemfile.lock +0 -202
- data/test/cases/adapter_test.rb +0 -8
- data/test/cases/test_helper_test.rb +0 -226
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb158e4b3bbb44f1212648e777ca1701f5dab910
|
4
|
+
data.tar.gz: a93e0a2c4949b1a3e87024ada9508e0347f3ec84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f08d5d8a6466b54a798e988c50a8e27d6ab1c9273e5910e0c11b15a38facae0b7f75c3a5d5970b51178661f0a5e13ec624b36ffee97d1c64eae93c4946132f5
|
7
|
+
data.tar.gz: feef5212819586918cb91968980974c84a5e142ba94ace753d8cac05eb04e98fc3ebed1679c6582283791d8fe05ec44cea85d134e65ed75a42eb7f2a8c328e03
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,16 +4,22 @@ cache: bundler
|
|
4
4
|
language: ruby
|
5
5
|
|
6
6
|
matrix:
|
7
|
-
|
8
|
-
|
9
|
-
- rvm:
|
7
|
+
exclude:
|
8
|
+
# Rails 5.0 dropped support for Ruby <2.2
|
9
|
+
- rvm: 2.0
|
10
|
+
gemfile: Gemfile.activejob50
|
11
|
+
- rvm: 2.1
|
12
|
+
gemfile: Gemfile.activejob50
|
10
13
|
|
11
14
|
rvm:
|
15
|
+
- 2.0
|
12
16
|
- 2.1
|
13
|
-
- 2.2
|
17
|
+
- 2.2.2
|
14
18
|
- 2.3.1
|
15
|
-
|
16
|
-
|
19
|
+
|
20
|
+
gemfile:
|
21
|
+
- Gemfile.activejob42
|
22
|
+
- Gemfile.activejob50
|
17
23
|
|
18
24
|
script:
|
19
25
|
- bundle exec rubocop
|
data/Gemfile.activejob50
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :test, :integration do
|
6
|
+
# Queues
|
7
|
+
gem 'resque', require: false
|
8
|
+
gem 'resque-scheduler', require: false
|
9
|
+
gem 'sidekiq', require: false
|
10
|
+
gem 'delayed_job', require: false
|
11
|
+
gem 'delayed_job_active_record', require: false
|
12
|
+
gem 'que', require: false
|
13
|
+
gem 'backburner', require: false
|
14
|
+
gem 'sequel', require: false
|
15
|
+
|
16
|
+
# Specs
|
17
|
+
gem 'sqlite3'
|
18
|
+
gem 'pg'
|
19
|
+
gem 'rails', '~> 5.0'
|
20
|
+
|
21
|
+
gem 'pry'
|
22
|
+
end
|
data/README.md
CHANGED
@@ -118,6 +118,13 @@ just executing the logic in the `rescue_from`, which makes manual re-enqueueing
|
|
118
118
|
easier. On the other hand it does disable Sidekiq's automatic retrying for all
|
119
119
|
ActiveJob jobs.
|
120
120
|
|
121
|
+
Supported Versions
|
122
|
+
------------------
|
123
|
+
|
124
|
+
Rails 4.2 and 5.0 are supported, on all versions of MRI which they support, except
|
125
|
+
Ruby 1.9.3. Other Ruby runtimes (e.g. JRuby, Rubinius) probably work, but are not
|
126
|
+
tested in Travis CI.
|
127
|
+
|
121
128
|
Contributing
|
122
129
|
------------
|
123
130
|
|
data/lib/active_job/retry.rb
CHANGED
@@ -45,7 +45,9 @@ module ActiveJob
|
|
45
45
|
|
46
46
|
def included(base)
|
47
47
|
klass = self
|
48
|
-
base.define_singleton_method(:inherited)
|
48
|
+
base.define_singleton_method(:inherited) do |subclass|
|
49
|
+
subclass.send(:include, klass)
|
50
|
+
end
|
49
51
|
define_backoff_strategy(base)
|
50
52
|
define_retry_attempt_tracking(base)
|
51
53
|
define_retry_method(base)
|
@@ -102,10 +104,16 @@ module ActiveJob
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def check_adapter!
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
107
|
+
adapter = ActiveJob::Base.queue_adapter
|
108
|
+
adapter_name =
|
109
|
+
case adapter
|
110
|
+
when Class then adapter.name
|
111
|
+
else adapter.class.name
|
112
|
+
end
|
113
|
+
|
114
|
+
if PROBLEMATIC_ADAPTERS.include?(adapter_name)
|
115
|
+
warn("#{adapter_name} does not support delayed retries, so does not work with " \
|
116
|
+
'ActiveJob::Retry. You may experience strange behaviour.')
|
109
117
|
end
|
110
118
|
end
|
111
119
|
|
data/spec/retry_spec.rb
CHANGED
@@ -9,7 +9,7 @@ RSpec.describe ActiveJob::Retry do
|
|
9
9
|
def perform(*_args)
|
10
10
|
raise RuntimeError
|
11
11
|
end
|
12
|
-
end.include
|
12
|
+
end.send(:include, retry_instance)
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'constant strategy' do
|
@@ -63,7 +63,7 @@ RSpec.describe ActiveJob::Retry do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'allows overriding' do
|
66
|
-
subclass.include
|
66
|
+
subclass.send(:include, described_class.new(strategy: :constant))
|
67
67
|
expect(subclass.backoff_strategy).
|
68
68
|
to be_a(ActiveJob::Retry::ConstantBackoffStrategy)
|
69
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Seymour
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -115,8 +115,8 @@ files:
|
|
115
115
|
- ".rubocop.yml"
|
116
116
|
- ".travis.yml"
|
117
117
|
- CHANGELOG.md
|
118
|
-
- Gemfile
|
119
|
-
- Gemfile.
|
118
|
+
- Gemfile.activejob42
|
119
|
+
- Gemfile.activejob50
|
120
120
|
- LICENSE
|
121
121
|
- README.md
|
122
122
|
- Rakefile
|
@@ -150,7 +150,6 @@ files:
|
|
150
150
|
- test/adapters/sidekiq.rb
|
151
151
|
- test/adapters/sneakers.rb
|
152
152
|
- test/adapters/sucker_punch.rb
|
153
|
-
- test/cases/adapter_test.rb
|
154
153
|
- test/cases/callbacks_test.rb
|
155
154
|
- test/cases/job_serialization_test.rb
|
156
155
|
- test/cases/logging_test.rb
|
@@ -158,7 +157,6 @@ files:
|
|
158
157
|
- test/cases/queuing_test.rb
|
159
158
|
- test/cases/rescue_test.rb
|
160
159
|
- test/cases/test_case_test.rb
|
161
|
-
- test/cases/test_helper_test.rb
|
162
160
|
- test/helper.rb
|
163
161
|
- test/integration/queuing_test.rb
|
164
162
|
- test/jobs/callback_job.rb
|
data/Gemfile.lock
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
activejob-retry (0.6.1)
|
5
|
-
activejob (>= 4.2)
|
6
|
-
activesupport (>= 4.2)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionmailer (4.2.6)
|
12
|
-
actionpack (= 4.2.6)
|
13
|
-
actionview (= 4.2.6)
|
14
|
-
activejob (= 4.2.6)
|
15
|
-
mail (~> 2.5, >= 2.5.4)
|
16
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
-
actionpack (4.2.6)
|
18
|
-
actionview (= 4.2.6)
|
19
|
-
activesupport (= 4.2.6)
|
20
|
-
rack (~> 1.6)
|
21
|
-
rack-test (~> 0.6.2)
|
22
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
-
actionview (4.2.6)
|
25
|
-
activesupport (= 4.2.6)
|
26
|
-
builder (~> 3.1)
|
27
|
-
erubis (~> 2.7.0)
|
28
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
30
|
-
activejob (4.2.6)
|
31
|
-
activesupport (= 4.2.6)
|
32
|
-
globalid (>= 0.3.0)
|
33
|
-
activemodel (4.2.6)
|
34
|
-
activesupport (= 4.2.6)
|
35
|
-
builder (~> 3.1)
|
36
|
-
activerecord (4.2.6)
|
37
|
-
activemodel (= 4.2.6)
|
38
|
-
activesupport (= 4.2.6)
|
39
|
-
arel (~> 6.0)
|
40
|
-
activesupport (4.2.6)
|
41
|
-
i18n (~> 0.7)
|
42
|
-
json (~> 1.7, >= 1.7.7)
|
43
|
-
minitest (~> 5.1)
|
44
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
45
|
-
tzinfo (~> 1.1)
|
46
|
-
arel (6.0.3)
|
47
|
-
ast (2.2.0)
|
48
|
-
backburner (1.3.0)
|
49
|
-
beaneater (~> 1.0)
|
50
|
-
dante (> 0.1.5)
|
51
|
-
beaneater (1.0.0)
|
52
|
-
builder (3.2.2)
|
53
|
-
concurrent-ruby (1.0.2)
|
54
|
-
connection_pool (2.2.0)
|
55
|
-
dante (0.2.0)
|
56
|
-
delayed_job (4.1.2)
|
57
|
-
activesupport (>= 3.0, < 5.1)
|
58
|
-
delayed_job_active_record (4.1.1)
|
59
|
-
activerecord (>= 3.0, < 5.1)
|
60
|
-
delayed_job (>= 3.0, < 5)
|
61
|
-
diff-lcs (1.2.5)
|
62
|
-
erubis (2.7.0)
|
63
|
-
globalid (0.3.6)
|
64
|
-
activesupport (>= 4.1.0)
|
65
|
-
i18n (0.7.0)
|
66
|
-
json (1.8.3)
|
67
|
-
loofah (2.0.3)
|
68
|
-
nokogiri (>= 1.5.9)
|
69
|
-
mail (2.6.4)
|
70
|
-
mime-types (>= 1.16, < 4)
|
71
|
-
mime-types (3.0)
|
72
|
-
mime-types-data (~> 3.2015)
|
73
|
-
mime-types-data (3.2016.0221)
|
74
|
-
mini_portile2 (2.0.0)
|
75
|
-
minitest (5.9.0)
|
76
|
-
mono_logger (1.1.0)
|
77
|
-
multi_json (1.12.0)
|
78
|
-
nokogiri (1.6.7.2)
|
79
|
-
mini_portile2 (~> 2.0.0.rc2)
|
80
|
-
parser (2.3.1.0)
|
81
|
-
ast (~> 2.2)
|
82
|
-
pg (0.18.4)
|
83
|
-
powerpack (0.1.1)
|
84
|
-
que (0.11.5)
|
85
|
-
rack (1.6.4)
|
86
|
-
rack-protection (1.5.3)
|
87
|
-
rack
|
88
|
-
rack-test (0.6.3)
|
89
|
-
rack (>= 1.0)
|
90
|
-
rails (4.2.6)
|
91
|
-
actionmailer (= 4.2.6)
|
92
|
-
actionpack (= 4.2.6)
|
93
|
-
actionview (= 4.2.6)
|
94
|
-
activejob (= 4.2.6)
|
95
|
-
activemodel (= 4.2.6)
|
96
|
-
activerecord (= 4.2.6)
|
97
|
-
activesupport (= 4.2.6)
|
98
|
-
bundler (>= 1.3.0, < 2.0)
|
99
|
-
railties (= 4.2.6)
|
100
|
-
sprockets-rails
|
101
|
-
rails-deprecated_sanitizer (1.0.3)
|
102
|
-
activesupport (>= 4.2.0.alpha)
|
103
|
-
rails-dom-testing (1.0.7)
|
104
|
-
activesupport (>= 4.2.0.beta, < 5.0)
|
105
|
-
nokogiri (~> 1.6.0)
|
106
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
107
|
-
rails-html-sanitizer (1.0.3)
|
108
|
-
loofah (~> 2.0)
|
109
|
-
railties (4.2.6)
|
110
|
-
actionpack (= 4.2.6)
|
111
|
-
activesupport (= 4.2.6)
|
112
|
-
rake (>= 0.8.7)
|
113
|
-
thor (>= 0.18.1, < 2.0)
|
114
|
-
rainbow (2.1.0)
|
115
|
-
rake (11.1.2)
|
116
|
-
redis (3.3.0)
|
117
|
-
redis-namespace (1.5.2)
|
118
|
-
redis (~> 3.0, >= 3.0.4)
|
119
|
-
resque (1.26.0)
|
120
|
-
mono_logger (~> 1.0)
|
121
|
-
multi_json (~> 1.0)
|
122
|
-
redis-namespace (~> 1.3)
|
123
|
-
sinatra (>= 0.9.2)
|
124
|
-
vegas (~> 0.1.2)
|
125
|
-
resque-scheduler (4.2.0)
|
126
|
-
mono_logger (~> 1.0)
|
127
|
-
redis (~> 3.0)
|
128
|
-
resque (~> 1.25)
|
129
|
-
rufus-scheduler (~> 3.2)
|
130
|
-
rspec (3.4.0)
|
131
|
-
rspec-core (~> 3.4.0)
|
132
|
-
rspec-expectations (~> 3.4.0)
|
133
|
-
rspec-mocks (~> 3.4.0)
|
134
|
-
rspec-core (3.4.4)
|
135
|
-
rspec-support (~> 3.4.0)
|
136
|
-
rspec-expectations (3.4.0)
|
137
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
-
rspec-support (~> 3.4.0)
|
139
|
-
rspec-its (1.2.0)
|
140
|
-
rspec-core (>= 3.0.0)
|
141
|
-
rspec-expectations (>= 3.0.0)
|
142
|
-
rspec-mocks (3.4.1)
|
143
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
144
|
-
rspec-support (~> 3.4.0)
|
145
|
-
rspec-support (3.4.1)
|
146
|
-
rubocop (0.40.0)
|
147
|
-
parser (>= 2.3.1.0, < 3.0)
|
148
|
-
powerpack (~> 0.1)
|
149
|
-
rainbow (>= 1.99.1, < 3.0)
|
150
|
-
ruby-progressbar (~> 1.7)
|
151
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
152
|
-
ruby-progressbar (1.8.1)
|
153
|
-
rufus-scheduler (3.2.1)
|
154
|
-
sequel (4.34.0)
|
155
|
-
sidekiq (4.1.2)
|
156
|
-
concurrent-ruby (~> 1.0)
|
157
|
-
connection_pool (~> 2.2, >= 2.2.0)
|
158
|
-
redis (~> 3.2, >= 3.2.1)
|
159
|
-
sinatra (1.4.7)
|
160
|
-
rack (~> 1.5)
|
161
|
-
rack-protection (~> 1.4)
|
162
|
-
tilt (>= 1.3, < 3)
|
163
|
-
sprockets (3.6.0)
|
164
|
-
concurrent-ruby (~> 1.0)
|
165
|
-
rack (> 1, < 3)
|
166
|
-
sprockets-rails (3.0.4)
|
167
|
-
actionpack (>= 4.0)
|
168
|
-
activesupport (>= 4.0)
|
169
|
-
sprockets (>= 3.0.0)
|
170
|
-
sqlite3 (1.3.11)
|
171
|
-
thor (0.19.1)
|
172
|
-
thread_safe (0.3.5)
|
173
|
-
tilt (2.0.4)
|
174
|
-
tzinfo (1.2.2)
|
175
|
-
thread_safe (~> 0.1)
|
176
|
-
unicode-display_width (1.0.5)
|
177
|
-
vegas (0.1.11)
|
178
|
-
rack (>= 1.0.0)
|
179
|
-
|
180
|
-
PLATFORMS
|
181
|
-
ruby
|
182
|
-
|
183
|
-
DEPENDENCIES
|
184
|
-
activejob-retry!
|
185
|
-
backburner
|
186
|
-
delayed_job
|
187
|
-
delayed_job_active_record
|
188
|
-
pg
|
189
|
-
que
|
190
|
-
rails
|
191
|
-
rake (>= 10.3)
|
192
|
-
resque
|
193
|
-
resque-scheduler
|
194
|
-
rspec
|
195
|
-
rspec-its
|
196
|
-
rubocop
|
197
|
-
sequel
|
198
|
-
sidekiq
|
199
|
-
sqlite3
|
200
|
-
|
201
|
-
BUNDLED WITH
|
202
|
-
1.12.5
|
data/test/cases/adapter_test.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class AdapterTest < ActiveSupport::TestCase
|
4
|
-
test "should load #{ENV['AJADAPTER']} adapter" do
|
5
|
-
ActiveJob::Base.queue_adapter = ENV['AJADAPTER'].to_sym
|
6
|
-
assert_equal "active_job/queue_adapters/#{ENV['AJADAPTER']}_adapter".classify.constantize, ActiveJob::Base.queue_adapter
|
7
|
-
end
|
8
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'active_support/core_ext/time'
|
3
|
-
require 'active_support/core_ext/date'
|
4
|
-
require 'jobs/hello_job'
|
5
|
-
require 'jobs/logging_job'
|
6
|
-
require 'jobs/nested_job'
|
7
|
-
|
8
|
-
class EnqueuedJobsTest < ActiveJob::TestCase
|
9
|
-
def test_assert_enqueued_jobs
|
10
|
-
assert_nothing_raised do
|
11
|
-
assert_enqueued_jobs 1 do
|
12
|
-
HelloJob.perform_later('david')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_repeated_enqueued_jobs_calls
|
18
|
-
assert_nothing_raised do
|
19
|
-
assert_enqueued_jobs 1 do
|
20
|
-
HelloJob.perform_later('abdelkader')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_nothing_raised do
|
25
|
-
assert_enqueued_jobs 2 do
|
26
|
-
HelloJob.perform_later('sean')
|
27
|
-
HelloJob.perform_later('yves')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_assert_enqueued_jobs_with_no_block
|
33
|
-
assert_nothing_raised do
|
34
|
-
HelloJob.perform_later('rafael')
|
35
|
-
assert_enqueued_jobs 1
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_nothing_raised do
|
39
|
-
HelloJob.perform_later('aaron')
|
40
|
-
HelloJob.perform_later('matthew')
|
41
|
-
assert_enqueued_jobs 3
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_assert_no_enqueued_jobs_with_no_block
|
46
|
-
assert_nothing_raised do
|
47
|
-
assert_no_enqueued_jobs
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_assert_no_enqueued_jobs
|
52
|
-
assert_nothing_raised do
|
53
|
-
assert_no_enqueued_jobs do
|
54
|
-
HelloJob.perform_now
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_assert_enqueued_jobs_too_few_sent
|
60
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
61
|
-
assert_enqueued_jobs 2 do
|
62
|
-
HelloJob.perform_later('xavier')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
assert_match(/2 .* but 1/, error.message)
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_assert_enqueued_jobs_too_many_sent
|
70
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
71
|
-
assert_enqueued_jobs 1 do
|
72
|
-
HelloJob.perform_later('cristian')
|
73
|
-
HelloJob.perform_later('guillermo')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
assert_match(/1 .* but 2/, error.message)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_assert_no_enqueued_jobs_failure
|
81
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
82
|
-
assert_no_enqueued_jobs do
|
83
|
-
HelloJob.perform_later('jeremy')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_match(/0 .* but 1/, error.message)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_assert_enqueued_job
|
91
|
-
assert_enqueued_with(job: LoggingJob, queue: 'default') do
|
92
|
-
LoggingJob.set(wait_until: Date.tomorrow.noon).perform_later
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_assert_enqueued_job_failure
|
97
|
-
assert_raise ActiveSupport::TestCase::Assertion do
|
98
|
-
assert_enqueued_with(job: LoggingJob, queue: 'default') do
|
99
|
-
NestedJob.perform_later
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
104
|
-
assert_enqueued_with(job: NestedJob, queue: 'low') do
|
105
|
-
NestedJob.perform_later
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
assert_equal 'No enqueued job found with {:job=>NestedJob, :queue=>"low"}', error.message
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_assert_enqueued_job_args
|
113
|
-
assert_raise ArgumentError do
|
114
|
-
assert_enqueued_with(class: LoggingJob) do
|
115
|
-
NestedJob.set(wait_until: Date.tomorrow.noon).perform_later
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
class PerformedJobsTest < ActiveJob::TestCase
|
122
|
-
def test_assert_performed_jobs
|
123
|
-
assert_nothing_raised do
|
124
|
-
assert_performed_jobs 1 do
|
125
|
-
HelloJob.perform_later('david')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_repeated_performed_jobs_calls
|
131
|
-
assert_nothing_raised do
|
132
|
-
assert_performed_jobs 1 do
|
133
|
-
HelloJob.perform_later('abdelkader')
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
assert_nothing_raised do
|
138
|
-
assert_performed_jobs 2 do
|
139
|
-
HelloJob.perform_later('sean')
|
140
|
-
HelloJob.perform_later('yves')
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_assert_performed_jobs_with_no_block
|
146
|
-
assert_nothing_raised do
|
147
|
-
perform_enqueued_jobs do
|
148
|
-
HelloJob.perform_later('rafael')
|
149
|
-
end
|
150
|
-
assert_performed_jobs 1
|
151
|
-
end
|
152
|
-
|
153
|
-
assert_nothing_raised do
|
154
|
-
perform_enqueued_jobs do
|
155
|
-
HelloJob.perform_later('aaron')
|
156
|
-
HelloJob.perform_later('matthew')
|
157
|
-
assert_performed_jobs 3
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_assert_no_performed_jobs_with_no_block
|
163
|
-
assert_nothing_raised do
|
164
|
-
assert_no_performed_jobs
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_assert_no_performed_jobs
|
169
|
-
assert_nothing_raised do
|
170
|
-
assert_no_performed_jobs do
|
171
|
-
# empty block won't perform jobs
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_assert_performed_jobs_too_few_sent
|
177
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
178
|
-
assert_performed_jobs 2 do
|
179
|
-
HelloJob.perform_later('xavier')
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
assert_match(/2 .* but 1/, error.message)
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_assert_performed_jobs_too_many_sent
|
187
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
188
|
-
assert_performed_jobs 1 do
|
189
|
-
HelloJob.perform_later('cristian')
|
190
|
-
HelloJob.perform_later('guillermo')
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
assert_match(/1 .* but 2/, error.message)
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_assert_no_performed_jobs_failure
|
198
|
-
error = assert_raise ActiveSupport::TestCase::Assertion do
|
199
|
-
assert_no_performed_jobs do
|
200
|
-
HelloJob.perform_later('jeremy')
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
assert_match(/0 .* but 1/, error.message)
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_assert_performed_job
|
208
|
-
assert_performed_with(job: NestedJob, queue: 'default') do
|
209
|
-
NestedJob.perform_later
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_assert_performed_job_failure
|
214
|
-
assert_raise ActiveSupport::TestCase::Assertion do
|
215
|
-
assert_performed_with(job: LoggingJob, at: Date.tomorrow.noon, queue: 'default') do
|
216
|
-
NestedJob.set(wait_until: Date.tomorrow.noon).perform_later
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
assert_raise ActiveSupport::TestCase::Assertion do
|
221
|
-
assert_performed_with(job: NestedJob, at: Date.tomorrow.noon, queue: 'low') do
|
222
|
-
NestedJob.set(queue: 'low', wait_until: Date.tomorrow.noon).perform_later
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|