Permalink
Browse files

Merge branch 'master' of git://github.com/timmatheson/delayed_job int…

…o timmatheson/master
  • Loading branch information...
2 parents 2917b5f + d5cf56f commit 8df6837c08f45b45a74bf4f529ae7bfd90dd8941 @tobi committed Oct 13, 2009
Showing with 5 additions and 4 deletions.
  1. +2 −2 lib/delayed/job.rb
  2. +1 −0 spec/database.rb
  3. +2 −2 spec/job_spec.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
@@ -249,7 +249,7 @@ def attempt_to_load(klass)
# Note: This does not ping the DB to get the time, so all your clients
# must have syncronized clocks.
def self.db_time_now
- (ActiveRecord::Base.default_timezone == :utc) ? Time.now.utc : Time.now
+ (ActiveRecord::Base.default_timezone == :utc) ? Time.now.utc : Time.zone.now
end
protected
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
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

0 comments on commit 8df6837

Please sign in to comment.