delayed_job_on_steroids 1.7.3 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/delayed_job_on_steroids.gemspec +1 -1
- data/lib/delayed/job.rb +7 -1
- data/spec/database.rb +0 -1
- data/spec/job_spec.rb +19 -0
- data/tasks/tasks.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.4
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{delayed_job_on_steroids}
|
8
|
-
s.version = "1.7.
|
8
|
+
s.version = "1.7.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tobias L\303\274tke", "Aleksey Palazhchenko"]
|
data/lib/delayed/job.rb
CHANGED
@@ -253,7 +253,13 @@ module Delayed
|
|
253
253
|
# Note: This does not ping the DB to get the time, so all your clients
|
254
254
|
# must have syncronized clocks.
|
255
255
|
def self.db_time_now
|
256
|
-
|
256
|
+
if Time.zone
|
257
|
+
Time.zone.now
|
258
|
+
elsif ActiveRecord::Base.default_timezone == :utc
|
259
|
+
Time.now.utc
|
260
|
+
else
|
261
|
+
Time.now
|
262
|
+
end
|
257
263
|
end
|
258
264
|
|
259
265
|
protected
|
data/spec/database.rb
CHANGED
@@ -11,7 +11,6 @@ require 'spec'
|
|
11
11
|
ActiveRecord::Base.logger = Logger.new('/tmp/dj.log')
|
12
12
|
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => '/tmp/jobs.sqlite')
|
13
13
|
ActiveRecord::Migration.verbose = false
|
14
|
-
ActiveRecord::Base.default_timezone = :utc if Time.zone.nil?
|
15
14
|
|
16
15
|
ActiveRecord::Schema.define do
|
17
16
|
|
data/spec/job_spec.rb
CHANGED
@@ -378,5 +378,24 @@ describe Delayed::Job do
|
|
378
378
|
end
|
379
379
|
|
380
380
|
end
|
381
|
+
|
382
|
+
context "db_time_now" do
|
383
|
+
it "should return time in current time zone if set" do
|
384
|
+
Time.zone = 'Eastern Time (US & Canada)'
|
385
|
+
Delayed::Job.db_time_now.zone.should == 'EST'
|
386
|
+
end
|
387
|
+
|
388
|
+
it "should return UTC time if that is the AR default" do
|
389
|
+
Time.zone = nil
|
390
|
+
ActiveRecord::Base.default_timezone = :utc
|
391
|
+
Delayed::Job.db_time_now.zone.should == 'UTC'
|
392
|
+
end
|
393
|
+
|
394
|
+
it "should return local time if that is the AR default" do
|
395
|
+
Time.zone = nil
|
396
|
+
ActiveRecord::Base.default_timezone = :local
|
397
|
+
Delayed::Job.db_time_now.zone.should_not == 'UTC'
|
398
|
+
end
|
399
|
+
end
|
381
400
|
|
382
401
|
end
|
data/tasks/tasks.rb
CHANGED
@@ -8,7 +8,7 @@ namespace :jobs do
|
|
8
8
|
Delayed::Job.delete_all
|
9
9
|
end
|
10
10
|
|
11
|
-
desc "Start a delayed_job worker
|
11
|
+
desc "Start a delayed_job worker (options: MIN_PRIORITY, MAX_PRIORITY, JOB_TYPES)."
|
12
12
|
task :work => [:merb_env, :environment] do
|
13
13
|
Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'],
|
14
14
|
:job_types => ENV['JOB_TYPES']).start
|