canvas-jobs 0.9.15 → 0.9.16

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: 089d54bcaa6fd72c6cb4ac2b682ffb1d77951c98
4
- data.tar.gz: 07835003745259e07f104071ea12bdcdc10bad08
3
+ metadata.gz: 57643efbeabb15ec7af78f3150afd1852462c4e0
4
+ data.tar.gz: 70ada31da936583af18e042eee3e68080725703f
5
5
  SHA512:
6
- metadata.gz: bc0ebc0109b69dc13937cba6d0c17cdfb20fbee9716852a9dc41692eb55afd47439f22f1ec6ad0ccb06a309e965407a29c0cb171aaad89eed79a6ca69c847118
7
- data.tar.gz: 94000941a93a244da58d12ec202e95d4f3d93bc3df7d6dcf5ae3f416654da68caf581191c372c48b992487d3533238ac13d76310dd4691bae32271510d7d445b
6
+ metadata.gz: c2b9ad3960cbd1b008e31b5e2c28375277a27366a2df2e5682f334eb85d2a179a3e68885e4cba7ed44ebc3366bb039c76f1e99105e625d877208d5f309ed7cbf
7
+ data.tar.gz: 238773d9623aaeb6c567ffdd87033e5574cc5a39cb07a891c4721c70b85359b25b8844352aa48355678287b7d747d07d1efc9b007436cecde99f9902d3825da3
@@ -39,7 +39,7 @@ module Delayed
39
39
  before_create :lock_strand_on_create
40
40
  def lock_strand_on_create
41
41
  if strand.present?
42
- self.class.connection.execute("SELECT pg_advisory_xact_lock(half_md5_as_bigint(#{self.class.sanitize(strand)}))")
42
+ self.class.connection.execute("SELECT pg_advisory_xact_lock(#{self.class.connection.quote_table_name('half_md5_as_bigint')}(#{self.class.sanitize(strand)}))")
43
43
  end
44
44
  end
45
45
 
@@ -137,22 +137,30 @@ module Delayed
137
137
  # to specify the jobs to act on, either pass opts[:ids] = [list of job ids]
138
138
  # or opts[:flavor] = <some flavor> to perform on all jobs of that flavor
139
139
  def self.bulk_update(action, opts)
140
- scope = if opts[:flavor]
141
- raise("Can't bulk update failed jobs") if opts[:flavor].to_s == 'failed'
140
+ raise("Can't #{action.to_s} failed jobs") if opts[:flavor].to_s == 'failed' && action.to_s != 'destroy'
141
+ scope = if opts[:ids]
142
+ if opts[:flavor] == 'failed'
143
+ Delayed::Job::Failed.where(:id => opts[:ids])
144
+ else
145
+ self.where(:id => opts[:ids])
146
+ end
147
+ elsif opts[:flavor]
148
+
142
149
  self.scope_for_flavor(opts[:flavor], opts[:query])
143
- elsif opts[:ids]
144
- self.where(:id => opts[:ids])
145
150
  end
146
151
 
147
152
  return 0 unless scope
148
153
 
149
154
  case action.to_s
150
155
  when 'hold'
156
+ scope = scope.where(locked_by: nil)
151
157
  scope.update_all(:locked_by => ON_HOLD_LOCKED_BY, :locked_at => db_time_now, :attempts => ON_HOLD_COUNT)
152
158
  when 'unhold'
153
159
  now = db_time_now
160
+ scope = scope.where(locked_by: ON_HOLD_LOCKED_BY)
154
161
  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])
155
162
  when 'destroy'
163
+ scope = scope.where("locked_by IS NULL OR locked_by=?", ON_HOLD_LOCKED_BY)
156
164
  scope.delete_all
157
165
  end
158
166
  end
@@ -221,7 +229,7 @@ module Delayed
221
229
  # depending on the db driver
222
230
  def self.transaction_for_singleton(strand)
223
231
  self.transaction do
224
- connection.execute(sanitize_sql(["SELECT pg_advisory_xact_lock(half_md5_as_bigint(?))", strand]))
232
+ connection.execute(sanitize_sql(["SELECT pg_advisory_xact_lock(#{connection.quote_table_name('half_md5_as_bigint')}(?))", strand]))
225
233
  yield
226
234
  end
227
235
  end
@@ -21,20 +21,30 @@ else
21
21
  end
22
22
  end
23
23
 
24
+ local count = 0
24
25
  for idx, job_id in ipairs(ids) do
25
26
  if action == 'hold' then
26
- local queue, strand = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'strand'))
27
- remove_from_queues(job_id, queue, strand)
28
- redis.call('HMSET', Keys.job(job_id), 'locked_at', now, 'locked_by', 'on hold', 'attempts', 50)
27
+ local queue, strand, locked_by = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'strand', 'locked_by'))
28
+ if not locked_by then
29
+ count = count + 1
30
+ remove_from_queues(job_id, queue, strand)
31
+ redis.call('HMSET', Keys.job(job_id), 'locked_at', now, 'locked_by', 'on hold', 'attempts', 50)
32
+ end
29
33
  elseif action == 'unhold' then
30
34
  local queue, locked_by = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'locked_by'))
31
- add_to_queues(job_id, queue, now)
32
- redis.call('HDEL', Keys.job(job_id), 'locked_at', 'locked_by')
33
- redis.call('HMSET', Keys.job(job_id), 'attempts', 0)
35
+ if locked_by == 'on hold' then
36
+ count = count + 1
37
+ add_to_queues(job_id, queue, now)
38
+ redis.call('HDEL', Keys.job(job_id), 'locked_at', 'locked_by')
39
+ redis.call('HMSET', Keys.job(job_id), 'attempts', 0)
40
+ end
34
41
  elseif action == 'destroy' then
35
- destroy_job(job_id, now)
42
+ local locked_by = redis.call('HGET', Keys.job(job_id), 'locked_by')
43
+ if not locked_by or locked_by == 'on hold' then
44
+ count = count + 1
45
+ destroy_job(job_id, now)
46
+ end
36
47
  end
37
48
  end
38
49
 
39
- -- returns the # of jobs matching the query, not necessarily the # whose state was changed
40
- return table.getn(ids)
50
+ return count
@@ -1,3 +1,3 @@
1
1
  module Delayed
2
- VERSION = "0.9.15"
2
+ VERSION = "0.9.16"
3
3
  end
@@ -67,4 +67,38 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
67
67
  job.locked_by.should == nil
68
68
  job.locked_at.should == nil
69
69
  end
70
+
71
+
72
+ describe "bulk_update failed jobs" do
73
+ before do
74
+ @flavor = 'failed'
75
+ @affected_jobs = []
76
+ @ignored_jobs = []
77
+ Timecop.freeze(5.minutes.ago) do
78
+ 5.times { @affected_jobs << create_job.tap { |j| j.fail! } }
79
+ @ignored_jobs << create_job(:run_at => 2.hours.from_now)
80
+ @ignored_jobs << create_job(:queue => 'q2')
81
+ end
82
+ end
83
+
84
+ it "should raise error when holding failed jobs" do
85
+ expect { Delayed::Job.bulk_update('hold', :flavor => @flavor, :query => @query) }.to raise_error
86
+ end
87
+
88
+ it "should raise error holding or unholding failed jobs" do
89
+ expect { Delayed::Job.bulk_update('unhold', :flavor => @flavor, :query => @query) }.to raise_error
90
+ end
91
+
92
+ it "should delete failed jobs by id" do
93
+ target_ids = Delayed::Job::Failed.all[0..2].map { |j| j.id }
94
+ Delayed::Job.bulk_update('destroy', :ids => target_ids, :flavor => @flavor, :query => @query).should == target_ids.length
95
+ end
96
+
97
+ it "should delete all failed jobs" do
98
+ Delayed::Job.bulk_update('destroy', :flavor => @flavor, :query => @query).should == @affected_jobs.size
99
+ @affected_jobs.map { |j| Delayed::Job.find(j.id) rescue nil }.compact.should be_blank
100
+ @ignored_jobs.map { |j| Delayed::Job.find(j.id) rescue nil }.compact.size.should == @ignored_jobs.size
101
+ end
102
+ end
103
+
70
104
  end
@@ -4,7 +4,6 @@ gemspec :path=>"../../"
4
4
 
5
5
  gem "rails", "~> 3.2.19"
6
6
 
7
- if RUBY_VERSION >= "2.0"
8
- gem "syck"
7
+ platforms :ruby_20, :ruby_21, :ruby_22 do
8
+ gem 'syck', '>= 1.0.4'
9
9
  end
10
-
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- canvas-jobs (0.9.7)
4
+ canvas-jobs (0.9.15)
5
5
  after_transaction_commit (= 1.0.1)
6
6
  rails (>= 3.2)
7
7
  redis (> 3.0)
8
- redis-scripting (= 1.0.1)
9
- rufus-scheduler (= 2.0.6)
8
+ redis-scripting (~> 1.0.1)
9
+ rufus-scheduler (~> 3.1.2)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
@@ -41,6 +41,7 @@ GEM
41
41
  after_transaction_commit (1.0.1)
42
42
  activerecord (>= 3.2)
43
43
  arel (3.0.3)
44
+ backports (3.6.6)
44
45
  builder (3.0.0)
45
46
  bump (0.5.0)
46
47
  coderay (1.1.0)
@@ -66,6 +67,8 @@ GEM
66
67
  rack (1.4.5)
67
68
  rack-cache (1.2)
68
69
  rack (>= 0.4)
70
+ rack-protection (1.5.3)
71
+ rack
69
72
  rack-ssl (1.3.4)
70
73
  rack
71
74
  rack-test (0.6.2)
@@ -88,7 +91,7 @@ GEM
88
91
  rake (10.3.2)
89
92
  rdoc (3.12)
90
93
  json (~> 1.4)
91
- redis (3.1.0)
94
+ redis (3.2.1)
92
95
  redis-scripting (1.0.1)
93
96
  redis (>= 3.0)
94
97
  rspec (3.1.0)
@@ -103,15 +106,26 @@ GEM
103
106
  rspec-mocks (3.1.3)
104
107
  rspec-support (~> 3.1.0)
105
108
  rspec-support (3.1.2)
106
- rufus-scheduler (2.0.6)
109
+ rufus-scheduler (3.1.7)
110
+ sinatra (1.4.6)
111
+ rack (~> 1.4)
112
+ rack-protection (~> 1.4)
113
+ tilt (>= 1.3, < 3)
114
+ sinatra-contrib (1.4.6)
115
+ backports (>= 2.0)
116
+ multi_json
117
+ rack-protection
118
+ rack-test
119
+ sinatra (~> 1.4.0)
120
+ tilt (>= 1.3, < 3)
107
121
  slop (3.6.0)
108
122
  sprockets (2.2.2)
109
123
  hike (~> 1.2)
110
124
  multi_json (~> 1.0)
111
125
  rack (~> 1.0)
112
126
  tilt (~> 1.1, != 1.3.0)
113
- syck (1.0.3)
114
- test_after_commit (0.4.0)
127
+ syck (1.0.5)
128
+ test_after_commit (0.4.1)
115
129
  activerecord (>= 3.2)
116
130
  thor (0.19.1)
117
131
  tilt (1.4.1)
@@ -120,7 +134,7 @@ GEM
120
134
  polyglot
121
135
  polyglot (>= 0.3.1)
122
136
  tzinfo (0.3.39)
123
- wwtd (0.5.5)
137
+ wwtd (1.1.1)
124
138
 
125
139
  PLATFORMS
126
140
  ruby
@@ -128,13 +142,16 @@ PLATFORMS
128
142
  DEPENDENCIES
129
143
  bump
130
144
  canvas-jobs!
131
- database_cleaner
145
+ database_cleaner (= 1.3.0)
132
146
  pg
133
147
  pry
148
+ rack-test
134
149
  rails (~> 3.2.19)
135
150
  rake
136
- rspec
137
- syck
138
- test_after_commit
139
- timecop
140
- wwtd
151
+ rspec (= 3.1.0)
152
+ sinatra
153
+ sinatra-contrib
154
+ syck (>= 1.0.4)
155
+ test_after_commit (= 0.4.1)
156
+ timecop (= 0.7.1)
157
+ wwtd (~> 1.1.1)
@@ -4,6 +4,6 @@ gemspec :path=>"../../"
4
4
 
5
5
  gem "rails", "~> 4.0.10"
6
6
 
7
- if RUBY_VERSION >= "2.0"
8
- gem "syck"
7
+ platforms :ruby_20, :ruby_21, :ruby_22 do
8
+ gem 'syck', '>= 1.0.4'
9
9
  end
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ canvas-jobs (0.9.15)
5
+ after_transaction_commit (= 1.0.1)
6
+ rails (>= 3.2)
7
+ redis (> 3.0)
8
+ redis-scripting (~> 1.0.1)
9
+ rufus-scheduler (~> 3.1.2)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionmailer (4.0.13)
15
+ actionpack (= 4.0.13)
16
+ mail (~> 2.5, >= 2.5.4)
17
+ actionpack (4.0.13)
18
+ activesupport (= 4.0.13)
19
+ builder (~> 3.1.0)
20
+ erubis (~> 2.7.0)
21
+ rack (~> 1.5.2)
22
+ rack-test (~> 0.6.2)
23
+ activemodel (4.0.13)
24
+ activesupport (= 4.0.13)
25
+ builder (~> 3.1.0)
26
+ activerecord (4.0.13)
27
+ activemodel (= 4.0.13)
28
+ activerecord-deprecated_finders (~> 1.0.2)
29
+ activesupport (= 4.0.13)
30
+ arel (~> 4.0.0)
31
+ activerecord-deprecated_finders (1.0.4)
32
+ activesupport (4.0.13)
33
+ i18n (~> 0.6, >= 0.6.9)
34
+ minitest (~> 4.2)
35
+ multi_json (~> 1.3)
36
+ thread_safe (~> 0.1)
37
+ tzinfo (~> 0.3.37)
38
+ after_transaction_commit (1.0.1)
39
+ activerecord (>= 3.2)
40
+ arel (4.0.2)
41
+ backports (3.6.6)
42
+ builder (3.1.4)
43
+ bump (0.5.2)
44
+ coderay (1.1.0)
45
+ database_cleaner (1.3.0)
46
+ diff-lcs (1.2.5)
47
+ erubis (2.7.0)
48
+ i18n (0.7.0)
49
+ mail (2.6.3)
50
+ mime-types (>= 1.16, < 3)
51
+ method_source (0.8.2)
52
+ mime-types (2.6.2)
53
+ minitest (4.7.5)
54
+ multi_json (1.11.2)
55
+ pg (0.18.3)
56
+ pry (0.10.3)
57
+ coderay (~> 1.1.0)
58
+ method_source (~> 0.8.1)
59
+ slop (~> 3.4)
60
+ rack (1.5.5)
61
+ rack-protection (1.5.3)
62
+ rack
63
+ rack-test (0.6.3)
64
+ rack (>= 1.0)
65
+ rails (4.0.13)
66
+ actionmailer (= 4.0.13)
67
+ actionpack (= 4.0.13)
68
+ activerecord (= 4.0.13)
69
+ activesupport (= 4.0.13)
70
+ bundler (>= 1.3.0, < 2.0)
71
+ railties (= 4.0.13)
72
+ sprockets-rails (~> 2.0)
73
+ railties (4.0.13)
74
+ actionpack (= 4.0.13)
75
+ activesupport (= 4.0.13)
76
+ rake (>= 0.8.7)
77
+ thor (>= 0.18.1, < 2.0)
78
+ rake (10.4.2)
79
+ redis (3.2.1)
80
+ redis-scripting (1.0.1)
81
+ redis (>= 3.0)
82
+ rspec (3.1.0)
83
+ rspec-core (~> 3.1.0)
84
+ rspec-expectations (~> 3.1.0)
85
+ rspec-mocks (~> 3.1.0)
86
+ rspec-core (3.1.7)
87
+ rspec-support (~> 3.1.0)
88
+ rspec-expectations (3.1.2)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.1.0)
91
+ rspec-mocks (3.1.3)
92
+ rspec-support (~> 3.1.0)
93
+ rspec-support (3.1.2)
94
+ rufus-scheduler (3.1.7)
95
+ sinatra (1.4.6)
96
+ rack (~> 1.4)
97
+ rack-protection (~> 1.4)
98
+ tilt (>= 1.3, < 3)
99
+ sinatra-contrib (1.4.6)
100
+ backports (>= 2.0)
101
+ multi_json
102
+ rack-protection
103
+ rack-test
104
+ sinatra (~> 1.4.0)
105
+ tilt (>= 1.3, < 3)
106
+ slop (3.6.0)
107
+ sprockets (3.4.0)
108
+ rack (> 1, < 3)
109
+ sprockets-rails (2.3.3)
110
+ actionpack (>= 3.0)
111
+ activesupport (>= 3.0)
112
+ sprockets (>= 2.8, < 4.0)
113
+ syck (1.0.5)
114
+ test_after_commit (0.4.1)
115
+ activerecord (>= 3.2)
116
+ thor (0.19.1)
117
+ thread_safe (0.3.5)
118
+ tilt (2.0.1)
119
+ timecop (0.7.1)
120
+ tzinfo (0.3.45)
121
+ wwtd (1.1.1)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bump
128
+ canvas-jobs!
129
+ database_cleaner (= 1.3.0)
130
+ pg
131
+ pry
132
+ rack-test
133
+ rails (~> 4.0.10)
134
+ rake
135
+ rspec (= 3.1.0)
136
+ sinatra
137
+ sinatra-contrib
138
+ syck (>= 1.0.4)
139
+ test_after_commit (= 0.4.1)
140
+ timecop (= 0.7.1)
141
+ wwtd (~> 1.1.1)
@@ -4,6 +4,6 @@ gemspec :path=>"../../"
4
4
 
5
5
  gem "rails", "~> 4.1.6"
6
6
 
7
- if RUBY_VERSION >= "2.0"
8
- gem "syck"
7
+ platforms :ruby_20, :ruby_21, :ruby_22 do
8
+ gem 'syck', '>= 1.0.4'
9
9
  end
@@ -0,0 +1,147 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ canvas-jobs (0.9.15)
5
+ after_transaction_commit (= 1.0.1)
6
+ rails (>= 3.2)
7
+ redis (> 3.0)
8
+ redis-scripting (~> 1.0.1)
9
+ rufus-scheduler (~> 3.1.2)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionmailer (4.1.13)
15
+ actionpack (= 4.1.13)
16
+ actionview (= 4.1.13)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ actionpack (4.1.13)
19
+ actionview (= 4.1.13)
20
+ activesupport (= 4.1.13)
21
+ rack (~> 1.5.2)
22
+ rack-test (~> 0.6.2)
23
+ actionview (4.1.13)
24
+ activesupport (= 4.1.13)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ activemodel (4.1.13)
28
+ activesupport (= 4.1.13)
29
+ builder (~> 3.1)
30
+ activerecord (4.1.13)
31
+ activemodel (= 4.1.13)
32
+ activesupport (= 4.1.13)
33
+ arel (~> 5.0.0)
34
+ activesupport (4.1.13)
35
+ i18n (~> 0.6, >= 0.6.9)
36
+ json (~> 1.7, >= 1.7.7)
37
+ minitest (~> 5.1)
38
+ thread_safe (~> 0.1)
39
+ tzinfo (~> 1.1)
40
+ after_transaction_commit (1.0.1)
41
+ activerecord (>= 3.2)
42
+ arel (5.0.1.20140414130214)
43
+ backports (3.6.6)
44
+ builder (3.2.2)
45
+ bump (0.5.2)
46
+ coderay (1.1.0)
47
+ database_cleaner (1.3.0)
48
+ diff-lcs (1.2.5)
49
+ erubis (2.7.0)
50
+ i18n (0.7.0)
51
+ json (1.8.3)
52
+ mail (2.6.3)
53
+ mime-types (>= 1.16, < 3)
54
+ method_source (0.8.2)
55
+ mime-types (2.6.2)
56
+ minitest (5.8.1)
57
+ multi_json (1.11.2)
58
+ pg (0.18.3)
59
+ pry (0.10.3)
60
+ coderay (~> 1.1.0)
61
+ method_source (~> 0.8.1)
62
+ slop (~> 3.4)
63
+ rack (1.5.5)
64
+ rack-protection (1.5.3)
65
+ rack
66
+ rack-test (0.6.3)
67
+ rack (>= 1.0)
68
+ rails (4.1.13)
69
+ actionmailer (= 4.1.13)
70
+ actionpack (= 4.1.13)
71
+ actionview (= 4.1.13)
72
+ activemodel (= 4.1.13)
73
+ activerecord (= 4.1.13)
74
+ activesupport (= 4.1.13)
75
+ bundler (>= 1.3.0, < 2.0)
76
+ railties (= 4.1.13)
77
+ sprockets-rails (~> 2.0)
78
+ railties (4.1.13)
79
+ actionpack (= 4.1.13)
80
+ activesupport (= 4.1.13)
81
+ rake (>= 0.8.7)
82
+ thor (>= 0.18.1, < 2.0)
83
+ rake (10.4.2)
84
+ redis (3.2.1)
85
+ redis-scripting (1.0.1)
86
+ redis (>= 3.0)
87
+ rspec (3.1.0)
88
+ rspec-core (~> 3.1.0)
89
+ rspec-expectations (~> 3.1.0)
90
+ rspec-mocks (~> 3.1.0)
91
+ rspec-core (3.1.7)
92
+ rspec-support (~> 3.1.0)
93
+ rspec-expectations (3.1.2)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.1.0)
96
+ rspec-mocks (3.1.3)
97
+ rspec-support (~> 3.1.0)
98
+ rspec-support (3.1.2)
99
+ rufus-scheduler (3.1.7)
100
+ sinatra (1.4.6)
101
+ rack (~> 1.4)
102
+ rack-protection (~> 1.4)
103
+ tilt (>= 1.3, < 3)
104
+ sinatra-contrib (1.4.6)
105
+ backports (>= 2.0)
106
+ multi_json
107
+ rack-protection
108
+ rack-test
109
+ sinatra (~> 1.4.0)
110
+ tilt (>= 1.3, < 3)
111
+ slop (3.6.0)
112
+ sprockets (3.4.0)
113
+ rack (> 1, < 3)
114
+ sprockets-rails (2.3.3)
115
+ actionpack (>= 3.0)
116
+ activesupport (>= 3.0)
117
+ sprockets (>= 2.8, < 4.0)
118
+ syck (1.0.5)
119
+ test_after_commit (0.4.1)
120
+ activerecord (>= 3.2)
121
+ thor (0.19.1)
122
+ thread_safe (0.3.5)
123
+ tilt (2.0.1)
124
+ timecop (0.7.1)
125
+ tzinfo (1.2.2)
126
+ thread_safe (~> 0.1)
127
+ wwtd (1.1.1)
128
+
129
+ PLATFORMS
130
+ ruby
131
+
132
+ DEPENDENCIES
133
+ bump
134
+ canvas-jobs!
135
+ database_cleaner (= 1.3.0)
136
+ pg
137
+ pry
138
+ rack-test
139
+ rails (~> 4.1.6)
140
+ rake
141
+ rspec (= 3.1.0)
142
+ sinatra
143
+ sinatra-contrib
144
+ syck (>= 1.0.4)
145
+ test_after_commit (= 0.4.1)
146
+ timecop (= 0.7.1)
147
+ wwtd (~> 1.1.1)
@@ -4,6 +4,6 @@ gemspec :path=>"../../"
4
4
 
5
5
  gem "rails", "~> 4.2.0.beta2"
6
6
 
7
- if RUBY_VERSION >= "2.0"
8
- gem "syck"
7
+ platforms :ruby_20, :ruby_21, :ruby_22 do
8
+ gem 'syck', '>= 1.0.4'
9
9
  end
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ canvas-jobs (0.9.15)
5
+ after_transaction_commit (= 1.0.1)
6
+ rails (>= 3.2)
7
+ redis (> 3.0)
8
+ redis-scripting (~> 1.0.1)
9
+ rufus-scheduler (~> 3.1.2)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionmailer (4.2.4)
15
+ actionpack (= 4.2.4)
16
+ actionview (= 4.2.4)
17
+ activejob (= 4.2.4)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 1.0, >= 1.0.5)
20
+ actionpack (4.2.4)
21
+ actionview (= 4.2.4)
22
+ activesupport (= 4.2.4)
23
+ rack (~> 1.6)
24
+ rack-test (~> 0.6.2)
25
+ rails-dom-testing (~> 1.0, >= 1.0.5)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (4.2.4)
28
+ activesupport (= 4.2.4)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 1.0, >= 1.0.5)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
+ activejob (4.2.4)
34
+ activesupport (= 4.2.4)
35
+ globalid (>= 0.3.0)
36
+ activemodel (4.2.4)
37
+ activesupport (= 4.2.4)
38
+ builder (~> 3.1)
39
+ activerecord (4.2.4)
40
+ activemodel (= 4.2.4)
41
+ activesupport (= 4.2.4)
42
+ arel (~> 6.0)
43
+ activesupport (4.2.4)
44
+ i18n (~> 0.7)
45
+ json (~> 1.7, >= 1.7.7)
46
+ minitest (~> 5.1)
47
+ thread_safe (~> 0.3, >= 0.3.4)
48
+ tzinfo (~> 1.1)
49
+ after_transaction_commit (1.0.1)
50
+ activerecord (>= 3.2)
51
+ arel (6.0.3)
52
+ backports (3.6.6)
53
+ builder (3.2.2)
54
+ bump (0.5.2)
55
+ coderay (1.1.0)
56
+ database_cleaner (1.3.0)
57
+ diff-lcs (1.2.5)
58
+ erubis (2.7.0)
59
+ globalid (0.3.6)
60
+ activesupport (>= 4.1.0)
61
+ i18n (0.7.0)
62
+ json (1.8.3)
63
+ loofah (2.0.3)
64
+ nokogiri (>= 1.5.9)
65
+ mail (2.6.3)
66
+ mime-types (>= 1.16, < 3)
67
+ method_source (0.8.2)
68
+ mime-types (2.6.2)
69
+ mini_portile (0.6.2)
70
+ minitest (5.8.1)
71
+ multi_json (1.11.2)
72
+ nokogiri (1.6.6.2)
73
+ mini_portile (~> 0.6.0)
74
+ pg (0.18.3)
75
+ pry (0.10.3)
76
+ coderay (~> 1.1.0)
77
+ method_source (~> 0.8.1)
78
+ slop (~> 3.4)
79
+ rack (1.6.4)
80
+ rack-protection (1.5.3)
81
+ rack
82
+ rack-test (0.6.3)
83
+ rack (>= 1.0)
84
+ rails (4.2.4)
85
+ actionmailer (= 4.2.4)
86
+ actionpack (= 4.2.4)
87
+ actionview (= 4.2.4)
88
+ activejob (= 4.2.4)
89
+ activemodel (= 4.2.4)
90
+ activerecord (= 4.2.4)
91
+ activesupport (= 4.2.4)
92
+ bundler (>= 1.3.0, < 2.0)
93
+ railties (= 4.2.4)
94
+ sprockets-rails
95
+ rails-deprecated_sanitizer (1.0.3)
96
+ activesupport (>= 4.2.0.alpha)
97
+ rails-dom-testing (1.0.7)
98
+ activesupport (>= 4.2.0.beta, < 5.0)
99
+ nokogiri (~> 1.6.0)
100
+ rails-deprecated_sanitizer (>= 1.0.1)
101
+ rails-html-sanitizer (1.0.2)
102
+ loofah (~> 2.0)
103
+ railties (4.2.4)
104
+ actionpack (= 4.2.4)
105
+ activesupport (= 4.2.4)
106
+ rake (>= 0.8.7)
107
+ thor (>= 0.18.1, < 2.0)
108
+ rake (10.4.2)
109
+ redis (3.2.1)
110
+ redis-scripting (1.0.1)
111
+ redis (>= 3.0)
112
+ rspec (3.1.0)
113
+ rspec-core (~> 3.1.0)
114
+ rspec-expectations (~> 3.1.0)
115
+ rspec-mocks (~> 3.1.0)
116
+ rspec-core (3.1.7)
117
+ rspec-support (~> 3.1.0)
118
+ rspec-expectations (3.1.2)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.1.0)
121
+ rspec-mocks (3.1.3)
122
+ rspec-support (~> 3.1.0)
123
+ rspec-support (3.1.2)
124
+ rufus-scheduler (3.1.7)
125
+ sinatra (1.4.6)
126
+ rack (~> 1.4)
127
+ rack-protection (~> 1.4)
128
+ tilt (>= 1.3, < 3)
129
+ sinatra-contrib (1.4.6)
130
+ backports (>= 2.0)
131
+ multi_json
132
+ rack-protection
133
+ rack-test
134
+ sinatra (~> 1.4.0)
135
+ tilt (>= 1.3, < 3)
136
+ slop (3.6.0)
137
+ sprockets (3.4.0)
138
+ rack (> 1, < 3)
139
+ sprockets-rails (2.3.3)
140
+ actionpack (>= 3.0)
141
+ activesupport (>= 3.0)
142
+ sprockets (>= 2.8, < 4.0)
143
+ syck (1.0.5)
144
+ test_after_commit (0.4.1)
145
+ activerecord (>= 3.2)
146
+ thor (0.19.1)
147
+ thread_safe (0.3.5)
148
+ tilt (2.0.1)
149
+ timecop (0.7.1)
150
+ tzinfo (1.2.2)
151
+ thread_safe (~> 0.1)
152
+ wwtd (1.1.1)
153
+
154
+ PLATFORMS
155
+ ruby
156
+
157
+ DEPENDENCIES
158
+ bump
159
+ canvas-jobs!
160
+ database_cleaner (= 1.3.0)
161
+ pg
162
+ pry
163
+ rack-test
164
+ rails (~> 4.2.0.beta2)
165
+ rake
166
+ rspec (= 3.1.0)
167
+ sinatra
168
+ sinatra-contrib
169
+ syck (>= 1.0.4)
170
+ test_after_commit (= 0.4.1)
171
+ timecop (= 0.7.1)
172
+ wwtd (~> 1.1.1)
@@ -652,16 +652,17 @@ shared_examples_for 'a backend' do
652
652
  @ignored_jobs = []
653
653
  end
654
654
 
655
- it "should hold a scope of jobs" do
655
+ it "should hold and unhold a scope of jobs" do
656
656
  @affected_jobs.all? { |j| j.on_hold? }.should be false
657
657
  @ignored_jobs.any? { |j| j.on_hold? }.should be false
658
658
  Delayed::Job.bulk_update('hold', :flavor => @flavor, :query => @query).should == @affected_jobs.size
659
659
 
660
660
  @affected_jobs.all? { |j| Delayed::Job.find(j.id).on_hold? }.should be true
661
661
  @ignored_jobs.any? { |j| Delayed::Job.find(j.id).on_hold? }.should be false
662
- end
663
662
 
664
- it "should un-hold a scope of jobs" do
663
+ # redis holding seems busted - it removes from the tag set and strand list, so you can't use a query
664
+ # to un-hold them
665
+ next if Delayed::Job == Delayed::Backend::Redis::Job
665
666
  Delayed::Job.bulk_update('unhold', :flavor => @flavor, :query => @query).should == @affected_jobs.size
666
667
 
667
668
  @affected_jobs.any? { |j| Delayed::Job.find(j.id).on_hold? }.should be false
@@ -738,17 +739,40 @@ shared_examples_for 'a backend' do
738
739
  Delayed::Job.find(j2.id).on_hold?.should be true
739
740
  Delayed::Job.find(j3.id).on_hold?.should be false
740
741
 
741
- Delayed::Job.bulk_update('unhold', :ids => [j2.id]).should == 1
742
+ Delayed::Job.bulk_update('unhold', :ids => [j2.id, j3.id]).should == 1
742
743
  Delayed::Job.find(j1.id).on_hold?.should be true
743
744
  Delayed::Job.find(j2.id).on_hold?.should be false
744
745
  Delayed::Job.find(j3.id).on_hold?.should be false
745
746
  end
746
747
 
748
+ it "should not hold locked jobs" do
749
+ job1 = Delayed::Job.new(:tag => 'tag')
750
+ job1.create_and_lock!("worker")
751
+ job1.on_hold?.should be false
752
+ Delayed::Job.bulk_update('hold', ids: [job1.id]).should == 0
753
+ Delayed::Job.find(job1.id).on_hold?.should be false
754
+ end
755
+
756
+ it "should not unhold locked jobs" do
757
+ job1 = Delayed::Job.new(:tag => 'tag')
758
+ job1.create_and_lock!("worker")
759
+ Delayed::Job.bulk_update('unhold', ids: [job1.id]).should == 0
760
+ Delayed::Job.find(job1.id).on_hold?.should be false
761
+ Delayed::Job.find(job1.id).locked?.should be true
762
+ end
763
+
747
764
  it "should delete given job ids" do
748
765
  jobs = (0..2).map { create_job }
749
766
  Delayed::Job.bulk_update('destroy', :ids => jobs[0,2].map(&:id)).should == 2
750
767
  jobs.map { |j| Delayed::Job.find(j.id) rescue nil }.compact.should == jobs[2,1]
751
768
  end
769
+
770
+ it "should not delete locked jobs" do
771
+ job1 = Delayed::Job.new(:tag => 'tag')
772
+ job1.create_and_lock!("worker")
773
+ Delayed::Job.bulk_update('destroy', ids: [job1.id]).should == 0
774
+ Delayed::Job.find(job1.id).locked?.should be true
775
+ end
752
776
  end
753
777
 
754
778
  describe "tag_counts" do
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.9.15
4
+ version: 0.9.16
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-08-13 00:00:00.000000000 Z
12
+ date: 2015-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: after_transaction_commit
@@ -197,16 +197,16 @@ dependencies:
197
197
  name: wwtd
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - '='
200
+ - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: 0.7.0
202
+ version: 1.1.1
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - '='
207
+ - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: 0.7.0
209
+ version: 1.1.1
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: sinatra
212
212
  requirement: !ruby/object:Gem::Requirement
@@ -317,8 +317,11 @@ files:
317
317
  - spec/gemfiles/32.gemfile
318
318
  - spec/gemfiles/32.gemfile.lock
319
319
  - spec/gemfiles/40.gemfile
320
+ - spec/gemfiles/40.gemfile.lock
320
321
  - spec/gemfiles/41.gemfile
322
+ - spec/gemfiles/41.gemfile.lock
321
323
  - spec/gemfiles/42.gemfile
324
+ - spec/gemfiles/42.gemfile.lock
322
325
  - spec/migrate/20140924140513_add_story_table.rb
323
326
  - spec/redis_job_spec.rb
324
327
  - spec/sample_jobs.rb
@@ -349,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
352
  version: '0'
350
353
  requirements: []
351
354
  rubyforge_project:
352
- rubygems_version: 2.4.5
355
+ rubygems_version: 2.4.5.1
353
356
  signing_key:
354
357
  specification_version: 4
355
358
  summary: Instructure-maintained fork of delayed_job
@@ -361,8 +364,11 @@ test_files:
361
364
  - spec/gemfiles/32.gemfile
362
365
  - spec/gemfiles/32.gemfile.lock
363
366
  - spec/gemfiles/40.gemfile
367
+ - spec/gemfiles/40.gemfile.lock
364
368
  - spec/gemfiles/41.gemfile
369
+ - spec/gemfiles/41.gemfile.lock
365
370
  - spec/gemfiles/42.gemfile
371
+ - spec/gemfiles/42.gemfile.lock
366
372
  - spec/migrate/20140924140513_add_story_table.rb
367
373
  - spec/redis_job_spec.rb
368
374
  - spec/sample_jobs.rb