inst-jobs 0.11.6 → 0.11.7

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: e21f31dc7f5360307577a7c3e31d1747f8b7359c
4
- data.tar.gz: 2191834aa82cf0a63065b9ac951f9aafbd78d391
3
+ metadata.gz: a2170987cb69f7ade5944dea6c79874867c04999
4
+ data.tar.gz: 274b57c924601a2a0e0196c9f72db968e22dc8d2
5
5
  SHA512:
6
- metadata.gz: 6558c7935c3dc4347a47685527fec8c5529b610649ee4a26ddeb10216ca5e15e8ef154b4b6bb87088a347a7327678b4c19015d68b6e5ae2e799b585802197010
7
- data.tar.gz: ea259677667525224c10d0f73ee354b33e4e75b2fa78ae42ed406a42c293540f6cb3183c5a04da2b1ff3694e49f5e8b726132559575e62c8e02d7e1468f57cc7
6
+ metadata.gz: cf26bfccaa2b532ff7ae14a964d1c7c60ab88a7f30168bc2c503d723cc3bf758610965abc68cc5ae5b915c2c8b519f7794f3bfa0511c08b6d0afdf839de63671
7
+ data.tar.gz: 9ddc6fa740978e8cb4c323dde2832b957b30a361618776dc2fdb56f696966e31bfe715f64ba51eee065b2952a184c4cabbaf3e967f973119bb789b11f3f2c47b
@@ -313,7 +313,7 @@ module Delayed
313
313
  rescue TypeError, LoadError, NameError => e
314
314
  raise DeserializationError,
315
315
  "Job failed to load: #{e.message}. Try to manually require the required file."
316
- rescue ArgumentError, Psych::SyntaxError => e
316
+ rescue Psych::SyntaxError => e
317
317
  raise DeserializationError,
318
318
  "YAML parsing error: #{e.message}. Probably not recoverable."
319
319
  end
@@ -98,24 +98,32 @@ module Delayed
98
98
  def add_send_later_methods(method, enqueue_args={}, default_async=false)
99
99
  aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
100
100
 
101
- with_method, without_method = "#{aliased_method}_with_send_later#{punctuation}", "#{aliased_method}_without_send_later#{punctuation}"
102
-
103
- define_method(with_method) do |*args|
104
- send_later_enqueue_args(without_method, enqueue_args, *args)
101
+ # we still need this for backwards compatibility
102
+ without_method = "#{aliased_method}_without_send_later#{punctuation}"
103
+
104
+ if public_method_defined?(method)
105
+ visibility = :public
106
+ elsif private_method_defined?(method)
107
+ visibility = :private
108
+ else
109
+ visibility = :protected
105
110
  end
106
- alias_method without_method, method
107
-
108
- if default_async
109
- alias_method method, with_method
110
- case
111
- when public_method_defined?(without_method)
112
- public method
113
- when protected_method_defined?(without_method)
114
- protected method
115
- when private_method_defined?(without_method)
116
- private method
111
+
112
+ generated_delayed_methods.class_eval(<<-EOF, __FILE__, __LINE__ + 1)
113
+ def #{without_method}(*args)
114
+ send(:#{method}, *args, synchronous: true)
117
115
  end
118
- end
116
+ #{visibility} :#{without_method}
117
+
118
+ def #{method}(*args, synchronous: #{!default_async})
119
+ if synchronous
120
+ super(*args)
121
+ else
122
+ send_later_enqueue_args(:#{method}, #{enqueue_args.inspect}, *args, synchronous: true)
123
+ end
124
+ end
125
+ #{visibility} :#{method}
126
+ EOF
119
127
  end
120
128
 
121
129
  def handle_asynchronously(method, enqueue_args={})
@@ -129,6 +137,13 @@ module Delayed
129
137
  def handle_asynchronously_if_production(method, enqueue_args={})
130
138
  add_send_later_methods(method, enqueue_args, Rails.env.production?)
131
139
  end
140
+
141
+ private def generated_delayed_methods
142
+ @generated_delayed_methods ||= Module.new.tap do |mod|
143
+ const_set(:DelayedMethods, mod)
144
+ prepend mod
145
+ end
146
+ end
132
147
  end
133
148
  end
134
149
  end
@@ -4,20 +4,10 @@ module Delayed
4
4
  class Periodic
5
5
  attr_reader :name, :cron
6
6
 
7
- yaml_as "tag:ruby.yaml.org,2002:Delayed::Periodic"
8
-
9
- def to_yaml(opts = {})
10
- YAML.quick_emit(self.object_id, opts) { |out| out.scalar(taguri, @name) }
11
- end
12
-
13
7
  def encode_with(coder)
14
8
  coder.scalar("!ruby/Delayed::Periodic", @name)
15
9
  end
16
10
 
17
- def self.yaml_new(klass, tag, val)
18
- self.scheduled[val] || raise(NameError, "job #{val} is no longer scheduled")
19
- end
20
-
21
11
  cattr_accessor :scheduled, :overrides
22
12
  self.scheduled = {}
23
13
  self.overrides = {}
@@ -1,3 +1,3 @@
1
1
  module Delayed
2
- VERSION = "0.11.6"
2
+ VERSION = "0.11.7"
3
3
  end
@@ -28,6 +28,17 @@ class Worker
28
28
  @lifecycle ||= Delayed::Lifecycle.new
29
29
  end
30
30
 
31
+ def self.current_job
32
+ Thread.current[:running_delayed_job]
33
+ end
34
+
35
+ def self.running_job(job)
36
+ Thread.current[:running_delayed_job] = job
37
+ yield
38
+ ensure
39
+ Thread.current[:running_delayed_job] = nil
40
+ end
41
+
31
42
  def initialize(options = {})
32
43
  @exit = false
33
44
  @parent_pid = options[:parent_pid]
@@ -192,22 +203,18 @@ class Worker
192
203
  # also set up a unique tmpdir, which will get removed at the end of the job.
193
204
  def configure_for_job(job)
194
205
  previous_tmpdir = ENV['TMPDIR']
195
- Thread.current[:running_delayed_job] = job
196
206
 
197
- dir = Dir.mktmpdir("job-#{job.id}-#{self.name.gsub(/[^\w\.]/, '.')}-")
198
- begin
199
- ENV['TMPDIR'] = dir
200
- yield
201
- ensure
202
- FileUtils.remove_entry(dir, true)
207
+ self.class.running_job(job) do
208
+ dir = Dir.mktmpdir("job-#{job.id}-#{self.name.gsub(/[^\w\.]/, '.')}-")
209
+ begin
210
+ ENV['TMPDIR'] = dir
211
+ yield
212
+ ensure
213
+ FileUtils.remove_entry(dir, true)
214
+ end
203
215
  end
204
216
  ensure
205
217
  ENV['TMPDIR'] = previous_tmpdir
206
- Thread.current[:running_delayed_job] = nil
207
- end
208
-
209
- def self.current_job
210
- Thread.current[:running_delayed_job]
211
218
  end
212
219
 
213
220
  # `sample` reports KB, not B
@@ -230,6 +237,5 @@ class Worker
230
237
  end
231
238
  end
232
239
  end
233
-
234
240
  end
235
241
  end
@@ -2,71 +2,28 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- # First, tell YAML how to load a Module. This depends on Rails .constantize and autoloading.
6
- YAML.add_ruby_type("object:Module") do |type, val|
7
- val.constantize
8
- end
9
-
5
+ # These two added domain types are for backwards compatibility with jobs created
6
+ # using the old syck tags, as syck didn't have built-in module/class dumping. We
7
+ # now use Psych's built-in tags, which are `!ruby/module` and `!ruby/class`. At
8
+ # some point we can remove these, once there are no more jobs in any queues with
9
+ # these tags.
10
10
  Psych.add_domain_type("ruby/object", "Module") do |type, val|
11
11
  val.constantize
12
12
  end
13
-
14
13
  Psych.add_domain_type("ruby/object", "Class") do |type, val|
15
14
  val.constantize
16
15
  end
17
16
 
18
- class Module
19
- def to_yaml(opts = {})
20
- YAML.quick_emit(self.object_id, opts) do |out|
21
- out.scalar(taguri, name)
22
- end
23
- end
24
- end
25
-
26
- # Now we have to do the same for Class.
27
- YAML.add_ruby_type("object:Class") do |type, val|
28
- val.constantize
29
- end
30
-
31
- class Class
32
- def to_yaml(opts = {})
33
- YAML.quick_emit(self.object_id, opts) do |out|
34
- out.scalar(taguri, name)
35
- end
36
- end
37
-
38
- def encode_with(coder)
39
- coder.scalar("!ruby/object:Class", name)
40
- end
41
- end
42
-
43
- # Now, tell YAML how to intelligently load ActiveRecord objects, using the
17
+ # Tell YAML how to intelligently load ActiveRecord objects, using the
44
18
  # database rather than just serializing their attributes to the YAML. This
45
19
  # ensures the object is up to date when we use it in the job.
46
20
  class ActiveRecord::Base
47
- yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"
48
-
49
- def to_yaml(opts = {})
50
- if id.nil?
51
- raise("Can't serialize unsaved ActiveRecord object for delayed job: #{self.inspect}")
52
- end
53
- YAML.quick_emit(self.object_id, opts) do |out|
54
- out.scalar(taguri, id.to_s)
55
- end
56
- end
57
-
58
21
  def encode_with(coder)
59
22
  if id.nil?
60
23
  raise("Can't serialize unsaved ActiveRecord object for delayed job: #{self.inspect}")
61
24
  end
62
25
  coder.scalar("!ruby/ActiveRecord:#{self.class.name}", id.to_s)
63
26
  end
64
-
65
- def self.yaml_new(klass, tag, val)
66
- klass.find(val)
67
- rescue ActiveRecord::RecordNotFound
68
- raise Delayed::Backend::RecordNotFound, "Couldn't find #{klass} with id #{val.inspect}"
69
- end
70
27
  end
71
28
 
72
29
  module Delayed
@@ -81,7 +38,9 @@ module Delayed
81
38
  rescue ActiveRecord::RecordNotFound
82
39
  raise Delayed::Backend::RecordNotFound, "Couldn't find #{klass} with id #{object.value.inspect}"
83
40
  end
84
- when "tag:ruby.yaml.org,2002:Delayed::Periodic", "!ruby/Delayed::Periodic", "!ruby/object:Delayed::Periodic"
41
+ when "!ruby/Delayed::Periodic", "!ruby/object:Delayed::Periodic"
42
+ # The 2nd ruby/object tag is no longer generated, but some existing
43
+ # jobs use that tag. We can remove it later once those are all gone.
85
44
  Delayed::Periodic.scheduled[object.value] || raise(NameError, "job #{object.value} is no longer scheduled")
86
45
  else
87
46
  super
@@ -99,11 +58,3 @@ module Delayed
99
58
  end
100
59
 
101
60
  Psych::Visitors::ToRuby.prepend(Delayed::PsychExt::ToRuby)
102
-
103
- # Load Module/Class from yaml tag.
104
- class Module
105
- def yaml_tag_read_class(name)
106
- name.constantize
107
- name
108
- end
109
- end
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ inst-jobs (0.11.3)
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
+ thor (>= 0.14.6, < 2.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (3.2.22.2)
16
+ actionpack (= 3.2.22.2)
17
+ mail (~> 2.5.4)
18
+ actionpack (3.2.22.2)
19
+ activemodel (= 3.2.22.2)
20
+ activesupport (= 3.2.22.2)
21
+ builder (~> 3.0.0)
22
+ erubis (~> 2.7.0)
23
+ journey (~> 1.0.4)
24
+ rack (~> 1.4.5)
25
+ rack-cache (~> 1.2)
26
+ rack-test (~> 0.6.1)
27
+ sprockets (~> 2.2.1)
28
+ activemodel (3.2.22.2)
29
+ activesupport (= 3.2.22.2)
30
+ builder (~> 3.0.0)
31
+ activerecord (3.2.22.2)
32
+ activemodel (= 3.2.22.2)
33
+ activesupport (= 3.2.22.2)
34
+ arel (~> 3.0.2)
35
+ tzinfo (~> 0.3.29)
36
+ activeresource (3.2.22.2)
37
+ activemodel (= 3.2.22.2)
38
+ activesupport (= 3.2.22.2)
39
+ activesupport (3.2.22.2)
40
+ i18n (~> 0.6, >= 0.6.4)
41
+ multi_json (~> 1.0)
42
+ after_transaction_commit (1.0.1)
43
+ activerecord (>= 3.2)
44
+ arel (3.0.3)
45
+ backports (3.6.8)
46
+ builder (3.0.4)
47
+ bump (0.5.3)
48
+ coderay (1.1.1)
49
+ database_cleaner (1.3.0)
50
+ diff-lcs (1.2.5)
51
+ erubis (2.7.0)
52
+ hike (1.2.3)
53
+ i18n (0.7.0)
54
+ journey (1.0.4)
55
+ json (1.8.3)
56
+ mail (2.5.4)
57
+ mime-types (~> 1.16)
58
+ treetop (~> 1.4.8)
59
+ method_source (0.8.2)
60
+ mime-types (1.25.1)
61
+ multi_json (1.12.1)
62
+ pg (0.18.4)
63
+ polyglot (0.3.5)
64
+ pry (0.10.4)
65
+ coderay (~> 1.1.0)
66
+ method_source (~> 0.8.1)
67
+ slop (~> 3.4)
68
+ rack (1.4.7)
69
+ rack-cache (1.6.1)
70
+ rack (>= 0.4)
71
+ rack-protection (1.5.3)
72
+ rack
73
+ rack-ssl (1.3.4)
74
+ rack
75
+ rack-test (0.6.3)
76
+ rack (>= 1.0)
77
+ rails (3.2.22.2)
78
+ actionmailer (= 3.2.22.2)
79
+ actionpack (= 3.2.22.2)
80
+ activerecord (= 3.2.22.2)
81
+ activeresource (= 3.2.22.2)
82
+ activesupport (= 3.2.22.2)
83
+ bundler (~> 1.0)
84
+ railties (= 3.2.22.2)
85
+ railties (3.2.22.2)
86
+ actionpack (= 3.2.22.2)
87
+ activesupport (= 3.2.22.2)
88
+ rack-ssl (~> 1.3.2)
89
+ rake (>= 0.8.7)
90
+ rdoc (~> 3.4)
91
+ thor (>= 0.14.6, < 2.0)
92
+ rake (11.2.2)
93
+ rdoc (3.12.2)
94
+ json (~> 1.4)
95
+ redis (3.3.1)
96
+ redis-scripting (1.0.1)
97
+ redis (>= 3.0)
98
+ rspec (3.4.0)
99
+ rspec-core (~> 3.4.0)
100
+ rspec-expectations (~> 3.4.0)
101
+ rspec-mocks (~> 3.4.0)
102
+ rspec-core (3.4.4)
103
+ rspec-support (~> 3.4.0)
104
+ rspec-expectations (3.4.0)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.4.0)
107
+ rspec-mocks (3.4.1)
108
+ diff-lcs (>= 1.2.0, < 2.0)
109
+ rspec-support (~> 3.4.0)
110
+ rspec-support (3.4.1)
111
+ rufus-scheduler (3.1.10)
112
+ sinatra (1.4.6)
113
+ rack (~> 1.4)
114
+ rack-protection (~> 1.4)
115
+ tilt (>= 1.3, < 3)
116
+ sinatra-contrib (1.4.7)
117
+ backports (>= 2.0)
118
+ multi_json
119
+ rack-protection
120
+ rack-test
121
+ sinatra (~> 1.4.0)
122
+ tilt (>= 1.3, < 3)
123
+ slop (3.6.0)
124
+ sprockets (2.2.3)
125
+ hike (~> 1.2)
126
+ multi_json (~> 1.0)
127
+ rack (~> 1.0)
128
+ tilt (~> 1.1, != 1.3.0)
129
+ test_after_commit (0.4.1)
130
+ activerecord (>= 3.2)
131
+ thor (0.19.1)
132
+ tilt (1.4.1)
133
+ timecop (0.7.1)
134
+ treetop (1.4.15)
135
+ polyglot
136
+ polyglot (>= 0.3.1)
137
+ tzinfo (0.3.51)
138
+ wwtd (1.3.0)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ bump
145
+ database_cleaner (= 1.3.0)
146
+ inst-jobs!
147
+ pg
148
+ pry
149
+ rack-test
150
+ rails (~> 3.2.19)
151
+ rake
152
+ rspec (= 3.4.0)
153
+ sinatra
154
+ sinatra-contrib
155
+ test_after_commit (= 0.4.1)
156
+ timecop (= 0.7.1)
157
+ wwtd (~> 1.3.0)
158
+
159
+ BUNDLED WITH
160
+ 1.12.5
@@ -0,0 +1,148 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ inst-jobs (0.11.3)
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
+ thor (>= 0.14.6, < 2.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (4.0.13)
16
+ actionpack (= 4.0.13)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ actionpack (4.0.13)
19
+ activesupport (= 4.0.13)
20
+ builder (~> 3.1.0)
21
+ erubis (~> 2.7.0)
22
+ rack (~> 1.5.2)
23
+ rack-test (~> 0.6.2)
24
+ activemodel (4.0.13)
25
+ activesupport (= 4.0.13)
26
+ builder (~> 3.1.0)
27
+ activerecord (4.0.13)
28
+ activemodel (= 4.0.13)
29
+ activerecord-deprecated_finders (~> 1.0.2)
30
+ activesupport (= 4.0.13)
31
+ arel (~> 4.0.0)
32
+ activerecord-deprecated_finders (1.0.4)
33
+ activesupport (4.0.13)
34
+ i18n (~> 0.6, >= 0.6.9)
35
+ minitest (~> 4.2)
36
+ multi_json (~> 1.3)
37
+ thread_safe (~> 0.1)
38
+ tzinfo (~> 0.3.37)
39
+ after_transaction_commit (1.0.1)
40
+ activerecord (>= 3.2)
41
+ arel (4.0.2)
42
+ backports (3.6.8)
43
+ builder (3.1.4)
44
+ bump (0.5.3)
45
+ coderay (1.1.1)
46
+ concurrent-ruby (1.0.2)
47
+ database_cleaner (1.3.0)
48
+ diff-lcs (1.2.5)
49
+ erubis (2.7.0)
50
+ i18n (0.7.0)
51
+ mail (2.6.4)
52
+ mime-types (>= 1.16, < 4)
53
+ method_source (0.8.2)
54
+ mime-types (3.1)
55
+ mime-types-data (~> 3.2015)
56
+ mime-types-data (3.2016.0521)
57
+ minitest (4.7.5)
58
+ multi_json (1.12.1)
59
+ pg (0.18.4)
60
+ pry (0.10.4)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.8.1)
63
+ slop (~> 3.4)
64
+ rack (1.5.5)
65
+ rack-protection (1.5.3)
66
+ rack
67
+ rack-test (0.6.3)
68
+ rack (>= 1.0)
69
+ rails (4.0.13)
70
+ actionmailer (= 4.0.13)
71
+ actionpack (= 4.0.13)
72
+ activerecord (= 4.0.13)
73
+ activesupport (= 4.0.13)
74
+ bundler (>= 1.3.0, < 2.0)
75
+ railties (= 4.0.13)
76
+ sprockets-rails (~> 2.0)
77
+ railties (4.0.13)
78
+ actionpack (= 4.0.13)
79
+ activesupport (= 4.0.13)
80
+ rake (>= 0.8.7)
81
+ thor (>= 0.18.1, < 2.0)
82
+ rake (11.2.2)
83
+ redis (3.3.1)
84
+ redis-scripting (1.0.1)
85
+ redis (>= 3.0)
86
+ rspec (3.4.0)
87
+ rspec-core (~> 3.4.0)
88
+ rspec-expectations (~> 3.4.0)
89
+ rspec-mocks (~> 3.4.0)
90
+ rspec-core (3.4.4)
91
+ rspec-support (~> 3.4.0)
92
+ rspec-expectations (3.4.0)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.4.0)
95
+ rspec-mocks (3.4.1)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.4.0)
98
+ rspec-support (3.4.1)
99
+ rufus-scheduler (3.1.10)
100
+ sinatra (1.4.7)
101
+ rack (~> 1.5)
102
+ rack-protection (~> 1.4)
103
+ tilt (>= 1.3, < 3)
104
+ sinatra-contrib (1.4.7)
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.6.3)
113
+ concurrent-ruby (~> 1.0)
114
+ rack (> 1, < 3)
115
+ sprockets-rails (2.3.3)
116
+ actionpack (>= 3.0)
117
+ activesupport (>= 3.0)
118
+ sprockets (>= 2.8, < 4.0)
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.5)
124
+ timecop (0.7.1)
125
+ tzinfo (0.3.51)
126
+ wwtd (1.3.0)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ bump
133
+ database_cleaner (= 1.3.0)
134
+ inst-jobs!
135
+ pg
136
+ pry
137
+ rack-test
138
+ rails (~> 4.0.10)
139
+ rake
140
+ rspec (= 3.4.0)
141
+ sinatra
142
+ sinatra-contrib
143
+ test_after_commit (= 0.4.1)
144
+ timecop (= 0.7.1)
145
+ wwtd (~> 1.3.0)
146
+
147
+ BUNDLED WITH
148
+ 1.12.5
@@ -0,0 +1,154 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ inst-jobs (0.11.3)
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
+ thor (>= 0.14.6, < 2.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (4.1.16)
16
+ actionpack (= 4.1.16)
17
+ actionview (= 4.1.16)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ actionpack (4.1.16)
20
+ actionview (= 4.1.16)
21
+ activesupport (= 4.1.16)
22
+ rack (~> 1.5.2)
23
+ rack-test (~> 0.6.2)
24
+ actionview (4.1.16)
25
+ activesupport (= 4.1.16)
26
+ builder (~> 3.1)
27
+ erubis (~> 2.7.0)
28
+ activemodel (4.1.16)
29
+ activesupport (= 4.1.16)
30
+ builder (~> 3.1)
31
+ activerecord (4.1.16)
32
+ activemodel (= 4.1.16)
33
+ activesupport (= 4.1.16)
34
+ arel (~> 5.0.0)
35
+ activesupport (4.1.16)
36
+ i18n (~> 0.6, >= 0.6.9)
37
+ json (~> 1.7, >= 1.7.7)
38
+ minitest (~> 5.1)
39
+ thread_safe (~> 0.1)
40
+ tzinfo (~> 1.1)
41
+ after_transaction_commit (1.0.1)
42
+ activerecord (>= 3.2)
43
+ arel (5.0.1.20140414130214)
44
+ backports (3.6.8)
45
+ builder (3.2.2)
46
+ bump (0.5.3)
47
+ coderay (1.1.1)
48
+ concurrent-ruby (1.0.2)
49
+ database_cleaner (1.3.0)
50
+ diff-lcs (1.2.5)
51
+ erubis (2.7.0)
52
+ i18n (0.7.0)
53
+ json (1.8.3)
54
+ mail (2.6.4)
55
+ mime-types (>= 1.16, < 4)
56
+ method_source (0.8.2)
57
+ mime-types (3.1)
58
+ mime-types-data (~> 3.2015)
59
+ mime-types-data (3.2016.0521)
60
+ minitest (5.9.0)
61
+ multi_json (1.12.1)
62
+ pg (0.18.4)
63
+ pry (0.10.4)
64
+ coderay (~> 1.1.0)
65
+ method_source (~> 0.8.1)
66
+ slop (~> 3.4)
67
+ rack (1.5.5)
68
+ rack-protection (1.5.3)
69
+ rack
70
+ rack-test (0.6.3)
71
+ rack (>= 1.0)
72
+ rails (4.1.16)
73
+ actionmailer (= 4.1.16)
74
+ actionpack (= 4.1.16)
75
+ actionview (= 4.1.16)
76
+ activemodel (= 4.1.16)
77
+ activerecord (= 4.1.16)
78
+ activesupport (= 4.1.16)
79
+ bundler (>= 1.3.0, < 2.0)
80
+ railties (= 4.1.16)
81
+ sprockets-rails (~> 2.0)
82
+ railties (4.1.16)
83
+ actionpack (= 4.1.16)
84
+ activesupport (= 4.1.16)
85
+ rake (>= 0.8.7)
86
+ thor (>= 0.18.1, < 2.0)
87
+ rake (11.2.2)
88
+ redis (3.3.1)
89
+ redis-scripting (1.0.1)
90
+ redis (>= 3.0)
91
+ rspec (3.4.0)
92
+ rspec-core (~> 3.4.0)
93
+ rspec-expectations (~> 3.4.0)
94
+ rspec-mocks (~> 3.4.0)
95
+ rspec-core (3.4.4)
96
+ rspec-support (~> 3.4.0)
97
+ rspec-expectations (3.4.0)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (~> 3.4.0)
100
+ rspec-mocks (3.4.1)
101
+ diff-lcs (>= 1.2.0, < 2.0)
102
+ rspec-support (~> 3.4.0)
103
+ rspec-support (3.4.1)
104
+ rufus-scheduler (3.1.10)
105
+ sinatra (1.4.7)
106
+ rack (~> 1.5)
107
+ rack-protection (~> 1.4)
108
+ tilt (>= 1.3, < 3)
109
+ sinatra-contrib (1.4.7)
110
+ backports (>= 2.0)
111
+ multi_json
112
+ rack-protection
113
+ rack-test
114
+ sinatra (~> 1.4.0)
115
+ tilt (>= 1.3, < 3)
116
+ slop (3.6.0)
117
+ sprockets (3.7.0)
118
+ concurrent-ruby (~> 1.0)
119
+ rack (> 1, < 3)
120
+ sprockets-rails (2.3.3)
121
+ actionpack (>= 3.0)
122
+ activesupport (>= 3.0)
123
+ sprockets (>= 2.8, < 4.0)
124
+ test_after_commit (0.4.1)
125
+ activerecord (>= 3.2)
126
+ thor (0.19.1)
127
+ thread_safe (0.3.5)
128
+ tilt (2.0.5)
129
+ timecop (0.7.1)
130
+ tzinfo (1.2.2)
131
+ thread_safe (~> 0.1)
132
+ wwtd (1.3.0)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ bump
139
+ database_cleaner (= 1.3.0)
140
+ inst-jobs!
141
+ pg
142
+ pry
143
+ rack-test
144
+ rails (~> 4.1.6)
145
+ rake
146
+ rspec (= 3.4.0)
147
+ sinatra
148
+ sinatra-contrib
149
+ test_after_commit (= 0.4.1)
150
+ timecop (= 0.7.1)
151
+ wwtd (~> 1.3.0)
152
+
153
+ BUNDLED WITH
154
+ 1.12.5
@@ -0,0 +1,181 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ inst-jobs (0.11.3)
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
+ thor (>= 0.14.6, < 2.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (4.2.7)
16
+ actionpack (= 4.2.7)
17
+ actionview (= 4.2.7)
18
+ activejob (= 4.2.7)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ actionpack (4.2.7)
22
+ actionview (= 4.2.7)
23
+ activesupport (= 4.2.7)
24
+ rack (~> 1.6)
25
+ rack-test (~> 0.6.2)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (4.2.7)
29
+ activesupport (= 4.2.7)
30
+ builder (~> 3.1)
31
+ erubis (~> 2.7.0)
32
+ rails-dom-testing (~> 1.0, >= 1.0.5)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
+ activejob (4.2.7)
35
+ activesupport (= 4.2.7)
36
+ globalid (>= 0.3.0)
37
+ activemodel (4.2.7)
38
+ activesupport (= 4.2.7)
39
+ builder (~> 3.1)
40
+ activerecord (4.2.7)
41
+ activemodel (= 4.2.7)
42
+ activesupport (= 4.2.7)
43
+ arel (~> 6.0)
44
+ activesupport (4.2.7)
45
+ i18n (~> 0.7)
46
+ json (~> 1.7, >= 1.7.7)
47
+ minitest (~> 5.1)
48
+ thread_safe (~> 0.3, >= 0.3.4)
49
+ tzinfo (~> 1.1)
50
+ after_transaction_commit (1.0.1)
51
+ activerecord (>= 3.2)
52
+ arel (6.0.3)
53
+ backports (3.6.8)
54
+ builder (3.2.2)
55
+ bump (0.5.3)
56
+ coderay (1.1.1)
57
+ concurrent-ruby (1.0.2)
58
+ database_cleaner (1.3.0)
59
+ diff-lcs (1.2.5)
60
+ erubis (2.7.0)
61
+ globalid (0.3.6)
62
+ activesupport (>= 4.1.0)
63
+ i18n (0.7.0)
64
+ json (1.8.3)
65
+ loofah (2.0.3)
66
+ nokogiri (>= 1.5.9)
67
+ mail (2.6.4)
68
+ mime-types (>= 1.16, < 4)
69
+ method_source (0.8.2)
70
+ mime-types (3.1)
71
+ mime-types-data (~> 3.2015)
72
+ mime-types-data (3.2016.0521)
73
+ mini_portile2 (2.1.0)
74
+ minitest (5.9.0)
75
+ multi_json (1.12.1)
76
+ nokogiri (1.6.8)
77
+ mini_portile2 (~> 2.1.0)
78
+ pkg-config (~> 1.1.7)
79
+ pg (0.18.4)
80
+ pkg-config (1.1.7)
81
+ pry (0.10.4)
82
+ coderay (~> 1.1.0)
83
+ method_source (~> 0.8.1)
84
+ slop (~> 3.4)
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.7)
91
+ actionmailer (= 4.2.7)
92
+ actionpack (= 4.2.7)
93
+ actionview (= 4.2.7)
94
+ activejob (= 4.2.7)
95
+ activemodel (= 4.2.7)
96
+ activerecord (= 4.2.7)
97
+ activesupport (= 4.2.7)
98
+ bundler (>= 1.3.0, < 2.0)
99
+ railties (= 4.2.7)
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.7)
110
+ actionpack (= 4.2.7)
111
+ activesupport (= 4.2.7)
112
+ rake (>= 0.8.7)
113
+ thor (>= 0.18.1, < 2.0)
114
+ rake (11.2.2)
115
+ redis (3.3.1)
116
+ redis-scripting (1.0.1)
117
+ redis (>= 3.0)
118
+ rspec (3.4.0)
119
+ rspec-core (~> 3.4.0)
120
+ rspec-expectations (~> 3.4.0)
121
+ rspec-mocks (~> 3.4.0)
122
+ rspec-core (3.4.4)
123
+ rspec-support (~> 3.4.0)
124
+ rspec-expectations (3.4.0)
125
+ diff-lcs (>= 1.2.0, < 2.0)
126
+ rspec-support (~> 3.4.0)
127
+ rspec-mocks (3.4.1)
128
+ diff-lcs (>= 1.2.0, < 2.0)
129
+ rspec-support (~> 3.4.0)
130
+ rspec-support (3.4.1)
131
+ rufus-scheduler (3.1.10)
132
+ sinatra (1.4.7)
133
+ rack (~> 1.5)
134
+ rack-protection (~> 1.4)
135
+ tilt (>= 1.3, < 3)
136
+ sinatra-contrib (1.4.7)
137
+ backports (>= 2.0)
138
+ multi_json
139
+ rack-protection
140
+ rack-test
141
+ sinatra (~> 1.4.0)
142
+ tilt (>= 1.3, < 3)
143
+ slop (3.6.0)
144
+ sprockets (3.7.0)
145
+ concurrent-ruby (~> 1.0)
146
+ rack (> 1, < 3)
147
+ sprockets-rails (3.1.1)
148
+ actionpack (>= 4.0)
149
+ activesupport (>= 4.0)
150
+ sprockets (>= 3.0.0)
151
+ test_after_commit (0.4.1)
152
+ activerecord (>= 3.2)
153
+ thor (0.19.1)
154
+ thread_safe (0.3.5)
155
+ tilt (2.0.5)
156
+ timecop (0.7.1)
157
+ tzinfo (1.2.2)
158
+ thread_safe (~> 0.1)
159
+ wwtd (1.3.0)
160
+
161
+ PLATFORMS
162
+ ruby
163
+
164
+ DEPENDENCIES
165
+ bump
166
+ database_cleaner (= 1.3.0)
167
+ inst-jobs!
168
+ pg
169
+ pry
170
+ rack-test
171
+ rails (~> 4.2.5)
172
+ rake
173
+ rspec (= 3.4.0)
174
+ sinatra
175
+ sinatra-contrib
176
+ test_after_commit (= 0.4.1)
177
+ timecop (= 0.7.1)
178
+ wwtd (~> 1.3.0)
179
+
180
+ BUNDLED WITH
181
+ 1.12.5
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path=>"../../"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+ gem 'sinatra', "2.0.0.beta2"
7
+ gem 'sinatra-contrib', "2.0.0.beta2"
@@ -33,28 +33,25 @@ shared_examples_for 'random ruby objects' do
33
33
  context "class methods" do
34
34
  context "add_send_later_methods" do
35
35
  it "should work with default_async" do
36
- class TestObject
36
+ klass = Class.new do
37
37
  attr_reader :ran
38
38
  def test_method; @ran = true; end
39
39
  add_send_later_methods :test_method, {}, true
40
40
  end
41
- obj = TestObject.new
41
+ obj = klass.new
42
42
  lambda { obj.test_method }.should change { Delayed::Job.jobs_count(:current) }.by(1)
43
- lambda { obj.test_method_with_send_later }.should change { Delayed::Job.jobs_count(:current) }.by(1)
44
43
  obj.ran.should be_falsey
45
44
  lambda { obj.test_method_without_send_later }.should_not change { Delayed::Job.jobs_count(:current) }
46
45
  obj.ran.should be true
47
46
  end
48
47
 
49
48
  it "should work without default_async" do
50
- class TestObject
49
+ klass = Class.new do
51
50
  attr_accessor :ran
52
51
  def test_method; @ran = true; end
53
52
  add_send_later_methods :test_method, {}, false
54
53
  end
55
- obj = TestObject.new
56
- lambda { obj.test_method_with_send_later }.should change { Delayed::Job.jobs_count(:current) }.by(1)
57
- obj.ran.should be_falsey
54
+ obj = klass.new
58
55
  lambda { obj.test_method }.should_not change { Delayed::Job.jobs_count(:current) }
59
56
  obj.ran.should be true
60
57
  obj.ran = false
@@ -64,57 +61,23 @@ shared_examples_for 'random ruby objects' do
64
61
  end
65
62
 
66
63
  it "should send along enqueue args and args default async" do
67
- class TestObject
68
- attr_reader :ran
64
+ klass = Class.new do
65
+ attr_accessor :ran
69
66
  def test_method(*args); @ran = args; end
70
67
  add_send_later_methods(:test_method, {:enqueue_arg_1 => :thing}, true)
71
68
  end
72
- obj = TestObject.new
69
+ obj = klass.new
73
70
  method = double()
74
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [1,2,3], nil, nil).and_return(method)
71
+
72
+ expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method, [1,2,3, {synchronous: true}], nil, nil).and_return(method)
75
73
  expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_1 => :thing)
76
74
  obj.test_method(1,2,3)
77
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [4], nil, nil).and_return(method)
75
+
76
+ expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method, [4, {:synchronous=>true}], nil, nil).and_return(method)
78
77
  expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_1 => :thing)
79
78
  obj.test_method(4)
80
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [6], nil, nil).and_return(method)
81
- expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_1 => :thing)
82
- obj.test_method_with_send_later(6)
83
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [5,6], nil, nil).and_return(method)
84
- expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_1 => :thing)
85
- obj.test_method_with_send_later(5,6)
86
- obj.ran.should be_nil
87
- obj.test_method_without_send_later(7)
88
- obj.ran.should == [7]
89
- obj.ran = nil
90
- obj.ran.should == nil
91
- obj.test_method_without_send_later(8,9)
92
- obj.ran.should == [8,9]
93
- end
94
79
 
95
- it "should send along enqueue args and args without default async" do
96
- class TestObject
97
- attr_reader :ran
98
- def test_method(*args); @ran = args; end
99
- add_send_later_methods(:test_method, {:enqueue_arg_2 => :thing2, :on_failure => :fail, :on_permanent_failure => :fail_frd}, false)
100
- end
101
- obj = TestObject.new
102
- method = double()
103
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [6], :fail, :fail_frd).and_return(method)
104
- expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_2 => :thing2)
105
- obj.test_method_with_send_later(6)
106
- expect(Delayed::PerformableMethod).to receive(:new).with(obj, :test_method_without_send_later, [5,6], :fail, :fail_frd).and_return(method)
107
- expect(Delayed::Job).to receive(:enqueue).with(method, :enqueue_arg_2 => :thing2)
108
- obj.test_method_with_send_later(5,6)
109
80
  obj.ran.should be_nil
110
- obj.test_method(1,2,3)
111
- obj.ran.should == [1,2,3]
112
- obj.ran = nil
113
- obj.ran.should == nil
114
- obj.test_method(4)
115
- obj.ran.should == [4]
116
- obj.ran = nil
117
- obj.ran.should == nil
118
81
  obj.test_method_without_send_later(7)
119
82
  obj.ran.should == [7]
120
83
  obj.ran = nil
@@ -124,28 +87,25 @@ shared_examples_for 'random ruby objects' do
124
87
  end
125
88
 
126
89
  it "should handle punctuation correctly with default_async" do
127
- class TestObject
90
+ klass = Class.new do
128
91
  attr_reader :ran
129
92
  def test_method?; @ran = true; end
130
93
  add_send_later_methods :test_method?, {}, true
131
94
  end
132
- obj = TestObject.new
95
+ obj = klass.new
133
96
  lambda { obj.test_method? }.should change { Delayed::Job.jobs_count(:current) }.by(1)
134
- lambda { obj.test_method_with_send_later? }.should change { Delayed::Job.jobs_count(:current) }.by(1)
135
97
  obj.ran.should be_falsey
136
98
  lambda { obj.test_method_without_send_later? }.should_not change { Delayed::Job.jobs_count(:current) }
137
99
  obj.ran.should be true
138
100
  end
139
101
 
140
102
  it "should handle punctuation correctly without default_async" do
141
- class TestObject
103
+ klass = Class.new do
142
104
  attr_accessor :ran
143
105
  def test_method?; @ran = true; end
144
106
  add_send_later_methods :test_method?, {}, false
145
107
  end
146
- obj = TestObject.new
147
- lambda { obj.test_method_with_send_later? }.should change { Delayed::Job.jobs_count(:current) }.by(1)
148
- obj.ran.should be_falsey
108
+ obj = klass.new
149
109
  lambda { obj.test_method? }.should_not change { Delayed::Job.jobs_count(:current) }
150
110
  obj.ran.should be true
151
111
  obj.ran = false
@@ -155,28 +115,25 @@ shared_examples_for 'random ruby objects' do
155
115
  end
156
116
 
157
117
  it "should handle assignment punctuation correctly with default_async" do
158
- class TestObject
118
+ klass = Class.new do
159
119
  attr_reader :ran
160
120
  def test_method=(val); @ran = val; end
161
121
  add_send_later_methods :test_method=, {}, true
162
122
  end
163
- obj = TestObject.new
123
+ obj = klass.new
164
124
  lambda { obj.test_method = 3 }.should change { Delayed::Job.jobs_count(:current) }.by(1)
165
- lambda { obj.test_method_with_send_later = 4 }.should change { Delayed::Job.jobs_count(:current) }.by(1)
166
125
  obj.ran.should be_nil
167
126
  lambda { obj.test_method_without_send_later = 5 }.should_not change { Delayed::Job.jobs_count(:current) }
168
127
  obj.ran.should == 5
169
128
  end
170
129
 
171
130
  it "should handle assignment punctuation correctly without default_async" do
172
- class TestObject
131
+ klass = Class.new do
173
132
  attr_accessor :ran
174
133
  def test_method=(val); @ran = val; end
175
134
  add_send_later_methods :test_method=, {}, false
176
135
  end
177
- obj = TestObject.new
178
- lambda { obj.test_method_with_send_later = 1 }.should change { Delayed::Job.jobs_count(:current) }.by(1)
179
- obj.ran.should be_nil
136
+ obj = klass.new
180
137
  lambda { obj.test_method = 2 }.should_not change { Delayed::Job.jobs_count(:current) }
181
138
  obj.ran.should == 2
182
139
  lambda { obj.test_method_without_send_later = 3 }.should_not change { Delayed::Job.jobs_count(:current) }
@@ -184,26 +141,26 @@ shared_examples_for 'random ruby objects' do
184
141
  end
185
142
 
186
143
  it "should correctly sort out method accessibility with default async" do
187
- class TestObject1
144
+ klass1 = Class.new do
188
145
  def test_method; end
189
146
  add_send_later_methods :test_method, {}, true
190
147
  end
191
- class TestObject2
148
+
149
+ klass2 = Class.new do
192
150
  protected
193
151
  def test_method; end
194
152
  add_send_later_methods :test_method, {}, true
195
153
  end
196
- class TestObject3
154
+
155
+ klass3 = Class.new do
197
156
  private
198
157
  def test_method; end
199
158
  add_send_later_methods :test_method, {}, true
200
159
  end
201
- TestObject1.public_method_defined?(:test_method).should be true
202
- TestObject2.public_method_defined?(:test_method).should be false
203
- TestObject3.public_method_defined?(:test_method).should be false
204
- TestObject2.protected_method_defined?(:test_method).should be true
205
- TestObject3.protected_method_defined?(:test_method).should be false
206
- TestObject3.private_method_defined?(:test_method).should be true
160
+
161
+ klass1.public_method_defined?(:test_method).should be true
162
+ klass2.protected_method_defined?(:test_method).should be true
163
+ klass3.private_method_defined?(:test_method).should be true
207
164
  end
208
165
  end
209
166
 
@@ -286,8 +243,8 @@ shared_examples_for 'random ruby objects' do
286
243
 
287
244
  job = Delayed::Job.list_jobs(:current, 1).first
288
245
  job.payload_object.class.should == Delayed::PerformableMethod
289
- job.payload_object.method.should == :whatever_without_send_later
290
- job.payload_object.args.should == [1, 5]
246
+ job.payload_object.method.should == :whatever
247
+ job.payload_object.args.should == [1, 5, {:synchronous=>true}]
291
248
  job.payload_object.perform.should == 'Once upon...'
292
249
  end
293
250
 
@@ -298,8 +255,8 @@ shared_examples_for 'random ruby objects' do
298
255
 
299
256
  job = Delayed::Job.list_jobs(:current, 1, 0, "testqueue").first
300
257
  job.payload_object.class.should == Delayed::PerformableMethod
301
- job.payload_object.method.should == :whatever_else_without_send_later
302
- job.payload_object.args.should == [1, 5]
258
+ job.payload_object.method.should == :whatever_else
259
+ job.payload_object.args.should == [1, 5, {:synchronous=>true}]
303
260
  job.payload_object.perform.should == 'Once upon...'
304
261
  end
305
262
 
@@ -327,14 +284,14 @@ shared_examples_for 'random ruby objects' do
327
284
  "string".send_at(1.hour.from_now, :length)
328
285
  end.should change { Delayed::Job.jobs_count(:future) }.by(1)
329
286
  end
330
-
287
+
331
288
  it "should schedule the job in the future" do
332
289
  time = 1.hour.from_now
333
290
  "string".send_at(time, :length)
334
291
  job = Delayed::Job.list_jobs(:future, 1).first
335
292
  job.run_at.to_i.should == time.to_i
336
293
  end
337
-
294
+
338
295
  it "should store payload as PerformableMethod" do
339
296
  "string".send_at(1.hour.from_now, :count, 'r')
340
297
  job = Delayed::Job.list_jobs(:future, 1).first
@@ -343,7 +300,7 @@ shared_examples_for 'random ruby objects' do
343
300
  job.payload_object.args.should == ['r']
344
301
  job.payload_object.perform.should == 1
345
302
  end
346
-
303
+
347
304
  it "should use the default queue if there is one" do
348
305
  set_queue("testqueue") do
349
306
  "string".send_at 1.hour.from_now, :reverse
@@ -359,14 +316,14 @@ shared_examples_for 'random ruby objects' do
359
316
  "string".send_at_with_queue(1.hour.from_now, :length, "testqueue")
360
317
  end.should change { Delayed::Job.jobs_count(:future, "testqueue") }.by(1)
361
318
  end
362
-
319
+
363
320
  it "should schedule the job in the future" do
364
321
  time = 1.hour.from_now
365
322
  "string".send_at_with_queue(time, :length, "testqueue")
366
323
  job = Delayed::Job.list_jobs(:future, 1, 0, "testqueue").first
367
324
  job.run_at.to_i.should == time.to_i
368
325
  end
369
-
326
+
370
327
  it "should override the default queue" do
371
328
  set_queue("default_queue") do
372
329
  "string".send_at_with_queue(1.hour.from_now, :length, "testqueue")
@@ -374,7 +331,7 @@ shared_examples_for 'random ruby objects' do
374
331
  job.queue.should == "testqueue"
375
332
  end
376
333
  end
377
-
334
+
378
335
  it "should store payload as PerformableMethod" do
379
336
  "string".send_at_with_queue(1.hour.from_now, :count, "testqueue", 'r')
380
337
  job = Delayed::Job.list_jobs(:future, 1, 0, "testqueue").first
@@ -415,5 +372,4 @@ shared_examples_for 'random ruby objects' do
415
372
  UnlessInJob.runs.should == 0
416
373
  end
417
374
  end
418
-
419
375
  end
data/spec/spec_helper.rb CHANGED
@@ -37,14 +37,22 @@ ENV['TEST_DB_DATABASE'] ||= "inst-jobs-test-#{ENV['TEST_ENV_NUMBER']}"
37
37
  ENV['TEST_REDIS_CONNECTION'] ||= 'redis://localhost:6379/'
38
38
 
39
39
  Delayed::Backend::Redis::Job.redis = Redis.new(url: ENV['TEST_REDIS_CONNECTION'])
40
+ Delayed::Backend::Redis::Job.redis.select ENV['TEST_ENV_NUMBER']
40
41
 
41
- ActiveRecord::Base.establish_connection({
42
+ connection_config = {
42
43
  adapter: :postgresql,
43
44
  host: ENV['TEST_DB_HOST'],
44
45
  encoding: 'utf8',
45
46
  username: ENV['TEST_DB_USERNAME'],
46
47
  database: ENV['TEST_DB_DATABASE'],
47
- })
48
+ }
49
+ # create the test db if it does not exist, to help out wwtd
50
+ ActiveRecord::Base.establish_connection(connection_config.merge(database: 'postgres'))
51
+ begin
52
+ ActiveRecord::Base.connection.create_database(connection_config[:database])
53
+ rescue ActiveRecord::StatementInvalid
54
+ end
55
+ ActiveRecord::Base.establish_connection(connection_config)
48
56
  # TODO reset db and migrate again, to test migrations
49
57
 
50
58
  ActiveRecord::Migrator.migrate("db/migrate")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.6
4
+ version: 0.11.7
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: 2016-12-06 00:00:00.000000000 Z
12
+ date: 2017-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: after_transaction_commit
@@ -328,9 +328,14 @@ files:
328
328
  - spec/delayed/work_queue/parent_process_spec.rb
329
329
  - spec/delayed/worker_spec.rb
330
330
  - spec/gemfiles/32.gemfile
331
+ - spec/gemfiles/32.gemfile.lock
331
332
  - spec/gemfiles/40.gemfile
333
+ - spec/gemfiles/40.gemfile.lock
332
334
  - spec/gemfiles/41.gemfile
335
+ - spec/gemfiles/41.gemfile.lock
333
336
  - spec/gemfiles/42.gemfile
337
+ - spec/gemfiles/42.gemfile.lock
338
+ - spec/gemfiles/50.gemfile
334
339
  - spec/migrate/20140924140513_add_story_table.rb
335
340
  - spec/redis_job_spec.rb
336
341
  - spec/sample_jobs.rb
@@ -361,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
366
  version: '0'
362
367
  requirements: []
363
368
  rubyforge_project:
364
- rubygems_version: 2.6.7
369
+ rubygems_version: 2.5.1
365
370
  signing_key:
366
371
  specification_version: 4
367
372
  summary: Instructure-maintained fork of delayed_job
@@ -375,9 +380,14 @@ test_files:
375
380
  - spec/delayed/work_queue/parent_process_spec.rb
376
381
  - spec/delayed/worker_spec.rb
377
382
  - spec/gemfiles/32.gemfile
383
+ - spec/gemfiles/32.gemfile.lock
378
384
  - spec/gemfiles/40.gemfile
385
+ - spec/gemfiles/40.gemfile.lock
379
386
  - spec/gemfiles/41.gemfile
387
+ - spec/gemfiles/41.gemfile.lock
380
388
  - spec/gemfiles/42.gemfile
389
+ - spec/gemfiles/42.gemfile.lock
390
+ - spec/gemfiles/50.gemfile
381
391
  - spec/migrate/20140924140513_add_story_table.rb
382
392
  - spec/redis_job_spec.rb
383
393
  - spec/sample_jobs.rb
@@ -389,4 +399,3 @@ test_files:
389
399
  - spec/shared/worker.rb
390
400
  - spec/shared_jobs_specs.rb
391
401
  - spec/spec_helper.rb
392
- has_rdoc: