Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove to_f in set method to prevent error #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/acidic_job/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def idempotency_key

# Configures the job with the given options.
def set(options = {}) # :nodoc:
self.scheduled_at = options[:wait].seconds.from_now.to_f if options[:wait]
self.scheduled_at = options[:wait_until].to_f if options[:wait_until]
self.scheduled_at = options[:wait].seconds.from_now if options[:wait]
self.scheduled_at = options[:wait_until] if options[:wait_until]
self.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
self.priority = options[:priority].to_i if options[:priority]

Expand Down
15 changes: 15 additions & 0 deletions test/cases/active_job/basics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Cases
module ActiveJob
class Basics < ActiveSupport::TestCase
include ::ActiveJob::TestHelper
include ActiveSupport::Testing::TimeHelpers

def before_setup
super()
Expand Down Expand Up @@ -384,6 +385,20 @@ def do_something
assert_equal "FINISHED", run.recovery_point
assert_equal 1, Performance.performances
end

test "job can be scheduled to be run in the future" do
class FutureJob < ::AcidicJob::Base
def perform; end
end

freeze_time

FutureJob.set(wait: 1.minute).perform_later
FutureJob.set(wait_until: 2.minutes.from_now).perform_later

assert_equal 1.minute.from_now, enqueued_jobs[0][:at]
assert_equal 2.minutes.from_now, enqueued_jobs[1][:at]
end
end
end
end
Expand Down