canvas-jobs 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeda81334fe194eb27996d982198016d7c4dd9a1
4
- data.tar.gz: c4698165803dc0ca24530a335e031d2f71725e69
3
+ metadata.gz: ea184ada62d200cf570338a65865761d2b168569
4
+ data.tar.gz: d11e965301438b83d7616bb76b98d42f4f6a5474
5
5
  SHA512:
6
- metadata.gz: d543d4c884dd14f0084091d6942247d4e6816a5f6d3e31d8ac2c1bb612aecc7402ff1759136dd70eb0e874120b3539218de3e6fbf8c82ba5210a9c613f388e95
7
- data.tar.gz: 0299d21693a0e48dfba4f56d7ca93d79c2355880637608650776012aa1a34047a322d0b47e8cd84e16afcb385ed39fa0c5b8a890f27535f803a1fe0848239b5d
6
+ metadata.gz: 376142657bad6c98367b711f03b7c9a269eb1b00545933ba367875c85e5e745ea46bf9ec5c37e17760f4fbb5758c80584b931b384fb3ff6e11bd3d2830de59b0
7
+ data.tar.gz: c56ed66abde1f4fe3dac5320d5c4e6406cfed5f20b62c465b8406ec1599ec312433af2341c1a60574d17573411eb03ef537c651bca10a029a0e2de7816a5a91f
@@ -167,7 +167,7 @@ module Delayed
167
167
  scope = scope.where(locked_by: ON_HOLD_LOCKED_BY)
168
168
  scope.update_all(["locked_by = NULL, locked_at = NULL, attempts = 0, run_at = (CASE WHEN run_at > ? THEN run_at ELSE ? END), failed_at = NULL", now, now])
169
169
  when 'destroy'
170
- scope = scope.where("locked_by IS NULL OR locked_by=?", ON_HOLD_LOCKED_BY)
170
+ scope = scope.where("locked_by IS NULL OR locked_by=?", ON_HOLD_LOCKED_BY) unless opts[:flavor] == 'failed'
171
171
  scope.delete_all
172
172
  end
173
173
  end
@@ -1,3 +1,3 @@
1
1
  module Delayed
2
- VERSION = "0.10.3"
2
+ VERSION = "0.10.4"
3
3
  end
@@ -69,34 +69,40 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
69
69
  end
70
70
 
71
71
  describe "bulk_update failed jobs" do
72
- before do
73
- @flavor = 'failed'
74
- @affected_jobs = []
75
- @ignored_jobs = []
76
- Timecop.freeze(5.minutes.ago) do
77
- 5.times { @affected_jobs << create_job.tap { |j| j.fail! } }
78
- @ignored_jobs << create_job(:run_at => 2.hours.from_now)
79
- @ignored_jobs << create_job(:queue => 'q2')
72
+ context "holding/unholding failed jobs" do
73
+ before :each do
74
+ @job = Delayed::Job.create :payload_object => SimpleJob.new
75
+ Delayed::Job.get_and_lock_next_available('worker1').should == @job
76
+ @job.fail!
80
77
  end
81
- end
82
78
 
83
- it "should raise error when holding failed jobs" do
84
- expect { Delayed::Job.bulk_update('hold', :flavor => @flavor, :query => @query) }.to raise_error
85
- end
79
+ it "should raise error when holding failed jobs" do
80
+ expect { Delayed::Job.bulk_update('hold', :flavor => 'failed', :query => @query) }.to raise_error
81
+ end
86
82
 
87
- it "should raise error holding or unholding failed jobs" do
88
- expect { Delayed::Job.bulk_update('unhold', :flavor => @flavor, :query => @query) }.to raise_error
83
+ it "should raise error unholding failed jobs" do
84
+ expect { Delayed::Job.bulk_update('unhold', :flavor => 'failed', :query => @query) }.to raise_error
85
+ end
89
86
  end
90
87
 
91
- it "should delete failed jobs by id" do
92
- target_ids = Delayed::Job::Failed.all[0..2].map { |j| j.id }
93
- Delayed::Job.bulk_update('destroy', :ids => target_ids, :flavor => @flavor, :query => @query).should == target_ids.length
94
- end
88
+ context "deleting failed jobs" do
89
+ before :each do
90
+ 2.times {
91
+ j = Delayed::Job.create(:payload_object => SimpleJob.new)
92
+ j.send(:lock_exclusively!, 'worker1').should == true
93
+ j.fail!
94
+ }
95
+ end
96
+
97
+ it "should delete failed jobs by id" do
98
+ target_ids = Delayed::Job::Failed.all[0..2].map { |j| j.id }
99
+ Delayed::Job.bulk_update('destroy', :ids => target_ids, :flavor => 'failed', :query => @query).should == target_ids.length
100
+ end
95
101
 
96
- it "should delete all failed jobs" do
97
- Delayed::Job.bulk_update('destroy', :flavor => @flavor, :query => @query).should == @affected_jobs.size
98
- @affected_jobs.map { |j| Delayed::Job.find(j.id) rescue nil }.compact.should be_blank
99
- @ignored_jobs.map { |j| Delayed::Job.find(j.id) rescue nil }.compact.size.should == @ignored_jobs.size
102
+ it "should delete all failed jobs" do
103
+ failed_count = Delayed::Job::Failed.count
104
+ Delayed::Job.bulk_update('destroy', :flavor => 'failed', :query => @query).should == failed_count
105
+ end
100
106
  end
101
107
  end
102
108
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-15 00:00:00.000000000 Z
12
+ date: 2016-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: after_transaction_commit
@@ -355,7 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
355
  version: '0'
356
356
  requirements: []
357
357
  rubyforge_project:
358
- rubygems_version: 2.4.5.1
358
+ rubygems_version: 2.5.1
359
359
  signing_key:
360
360
  specification_version: 4
361
361
  summary: Instructure-maintained fork of delayed_job