Skip to content

Commit

Permalink
fixing the Time.zone nil error, updating all specs to comply with the…
Browse files Browse the repository at this point in the history
… new code
  • Loading branch information
Tim Matheson committed Oct 12, 2009
1 parent bee4713 commit d5cf56f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/delayed/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d5cf56f

Please sign in to comment.