dalliance 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44670798d69664a8f7aeffb94d263c695dba015a2104fbad66897fc9ac4cad43
4
- data.tar.gz: 9e0c8a2cedbc449b693646332bb0cc6fc7dde070049d1baebaca6d2212f858e1
3
+ metadata.gz: e585e16bce792017e3427f68b18d991a5cdb3650b33703d56f1703240cfa3e09
4
+ data.tar.gz: 432c266fa7e05719f8074f615b439d9b9ae94ac06d429b0ff13740fabbb5f0bb
5
5
  SHA512:
6
- metadata.gz: c4017905c2346ffd4356a459ed24b0ab434285b5e20e001cb4f03c3a8775647b37afbbf67dd29820e92976b4f4293d36f6eb05bd1a3d3f98feca21f0b6684074
7
- data.tar.gz: b8a209af9448798a5d32210b7d9cfaa9c6395bea5ec579b0792ffc0fe4e8f04fbfa688c763f5d4f59e781d0b4b1efcbac6139d5cf3e412a54229c79589e2900c
6
+ metadata.gz: ab1f1ffb14924b56bcca0afe1601ac44489ed32a6bfbc56e4bc417f6849e26574c1c82204b8852db9853bb7437ac9939a9164d0a70e0accdc486136fb7f50398
7
+ data.tar.gz: 774cd874ad72796d024e2140889bc498332485ce5ec952a424f1ef03763cba580d302275923812882a5954f66a95f86079667b30db19ef37d986cb6b2f715f43
@@ -236,20 +236,21 @@ module Dalliance
236
236
  end
237
237
 
238
238
  def dalliance_background_reprocess(background_processing = nil)
239
+ # Reset state to 'pending' before queueing up
240
+ # Otherwise the model will stay on completed/processing_error until the job
241
+ # is taken by a worker, which could be a long time after this method is
242
+ # called.
243
+ reprocess_dalliance!
239
244
  if background_processing || (background_processing.nil? && self.class.dalliance_options[:background_processing])
240
- self.class.dalliance_options[:worker_class].enqueue(self, processing_queue, :dalliance_reprocess)
245
+ self.class.dalliance_options[:worker_class].enqueue(self, processing_queue, :do_dalliance_reprocess)
241
246
  else
242
- dalliance_reprocess(false)
247
+ do_dalliance_reprocess(false)
243
248
  end
244
249
  end
245
250
 
246
251
  def dalliance_reprocess(background_processing = false)
247
252
  reprocess_dalliance!
248
-
249
- do_dalliance_process(
250
- perform_method: self.class.dalliance_options[:reprocess_method],
251
- background_processing: background_processing
252
- )
253
+ do_dalliance_reprocess(background_processing)
253
254
  end
254
255
 
255
256
  def do_dalliance_process(perform_method:, background_processing: false)
@@ -339,6 +340,19 @@ module Dalliance
339
340
  end
340
341
  end
341
342
 
343
+ private
344
+
345
+ # Executes the reprocessing method defined in the model's dalliance options.
346
+ #
347
+ # @param [Boolean] background_processing
348
+ # flag if this is called from a background worker. Defaults to false.
349
+ def do_dalliance_reprocess(background_processing = false)
350
+ do_dalliance_process(
351
+ perform_method: self.class.dalliance_options[:reprocess_method],
352
+ background_processing: background_processing
353
+ )
354
+ end
355
+
342
356
  module Glue
343
357
  extend ActiveSupport::Concern
344
358
 
@@ -2,7 +2,7 @@ module Dalliance
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- TINY = 0
5
+ TINY = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -107,6 +107,16 @@ RSpec.describe DallianceModel do
107
107
 
108
108
  expect(subject.dalliance_duration).to be_between(original_duration, Float::INFINITY)
109
109
  end
110
+
111
+ it "resets the dalliance_status to 'pending'" do
112
+ subject.update_column(:dalliance_status, 'processing_error')
113
+ expect { subject.dalliance_background_reprocess }
114
+ .to change(subject, :dalliance_status)
115
+ .to('pending')
116
+
117
+ Delayed::Worker.new(:queues => [:dalliance]).work_off
118
+ expect(subject).to be_successful
119
+ end
110
120
  end
111
121
 
112
122
  context "another_queue" do
@@ -151,6 +151,21 @@ RSpec.describe DallianceModel do
151
151
 
152
152
  expect(subject.dalliance_duration).to be_between(original_duration, Float::INFINITY)
153
153
  end
154
+
155
+ it "resets the dalliance_status to 'pending'" do
156
+ subject.update_column(:dalliance_status, 'processing_error')
157
+
158
+ Resque::Stat.clear(:processed)
159
+ Resque::Stat.clear(:failed)
160
+
161
+ expect { subject.dalliance_background_reprocess }
162
+ .to change(subject, :dalliance_status)
163
+ .to('pending')
164
+
165
+ Resque::Worker.new(:dalliance).process
166
+
167
+ expect(subject).to be_successful
168
+ end
154
169
  end
155
170
 
156
171
  context "raise error" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalliance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Sullivan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-28 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -204,7 +204,7 @@ files:
204
204
  homepage: https://github.com/annkissam/dalliance
205
205
  licenses: []
206
206
  metadata: {}
207
- post_install_message:
207
+ post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths:
210
210
  - lib
@@ -219,9 +219,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubyforge_project:
222
+ rubyforge_project:
223
223
  rubygems_version: 2.7.6
224
- signing_key:
224
+ signing_key:
225
225
  specification_version: 4
226
226
  summary: Wrapper for an ActiveRecord model with a single ascynhronous method
227
227
  test_files: