Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing the Time.zone nil error, updating all specs to comply with the…

… new code
  • Loading branch information...
commit d5cf56fc85f9138d4da67d32128fe672d1289910 1 parent bee4713
Tim Matheson authored
Showing with 4 additions and 3 deletions.
  1. +1 −1  lib/delayed/job.rb
  2. +1 −0  spec/database.rb
  3. +2 −2 spec/job_spec.rb
2  lib/delayed/job.rb
View
@@ -73,7 +73,7 @@ def reschedule(message, backtrace = [], time = nil)
save!
else
logger.info "* [JOB] PERMANENTLY removing #{self.name} because of #{attempts} consequetive failures."
- destroy_failed_jobs ? destroy : update_attribute(:failed_at, Time.now)
+ destroy_failed_jobs ? destroy : update_attribute(:failed_at, Delayed::Job.db_time_now)
end
end
1  spec/database.rb
View
@@ -11,6 +11,7 @@
ActiveRecord::Base.logger = Logger.new('/tmp/dj.log')
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => '/tmp/jobs.sqlite')
ActiveRecord::Migration.verbose = false
+ActiveRecord::Base.default_timezone = :utc if Time.zone.nil?
ActiveRecord::Schema.define do
4 spec/job_spec.rb
View
@@ -54,7 +54,7 @@ def perform; @@runs += 1; end
end
it "should be able to set run_at when enqueuing items" do
- later = 5.minutes.from_now
+ later = (Delayed::Job.db_time_now+5.minutes)
Delayed::Job.enqueue SimpleJob.new, 5, later
# use be close rather than equal to because millisecond values cn be lost in DB round trip
@@ -172,7 +172,7 @@ def perform; @@runs += 1; end
end
it "should never find failed jobs" do
- @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50, :failed_at => Time.now
+ @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50, :failed_at => Delayed::Job.db_time_now
Delayed::Job.find_available(1).length.should == 0
end
Please sign in to comment.
Something went wrong with that request. Please try again.