aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/lib/action_mailer/message_delivery.rb21
-rw-r--r--actionmailer/test/message_delivery_test.rb8
-rw-r--r--activejob/lib/active_job/configured_job.rb2
-rw-r--r--activejob/lib/active_job/enqueuing.rb16
4 files changed, 22 insertions, 25 deletions
diff --git a/actionmailer/lib/action_mailer/message_delivery.rb b/actionmailer/lib/action_mailer/message_delivery.rb
index 8a6a8b631f..7118f9b02c 100644
--- a/actionmailer/lib/action_mailer/message_delivery.rb
+++ b/actionmailer/lib/action_mailer/message_delivery.rb
@@ -39,13 +39,13 @@ module ActionMailer
# and +raise_delivery_errors+, so use with caution.
#
# Notifier.welcome(User.first).deliver_later!
- # Notifier.welcome(User.first).deliver_later!(in: 1.hour)
- # Notifier.welcome(User.first).deliver_later!(at: 10.hours.from_now)
+ # Notifier.welcome(User.first).deliver_later!(wait: 1.hour)
+ # Notifier.welcome(User.first).deliver_later!(wait_until: 10.hours.from_now)
#
# Options:
#
- # * <tt>:in</tt> - Enqueue the email to be delivered with a delay
- # * <tt>:at</tt> - Enqueue the email to be delivered at (after) a specific date / time
+ # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay
+ # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time
def deliver_later!(options={})
enqueue_delivery :deliver_now!, options
end
@@ -54,13 +54,13 @@ module ActionMailer
# job runs it will send the email using +deliver_now+.
#
# Notifier.welcome(User.first).deliver_later
- # Notifier.welcome(User.first).deliver_later(in: 1.hour)
- # Notifier.welcome(User.first).deliver_later(at: 10.hours.from_now)
+ # Notifier.welcome(User.first).deliver_later(wait: 1.hour)
+ # Notifier.welcome(User.first).deliver_later(wait_until: 10.hours.from_now)
#
# Options:
#
- # * <tt>:in</tt> - Enqueue the email to be delivered with a delay
- # * <tt>:at</tt> - Enqueue the email to be delivered at (after) a specific date / time
+ # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay
+ # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time
def deliver_later(options={})
enqueue_delivery :deliver_now, options
end
@@ -98,10 +98,7 @@ module ActionMailer
def enqueue_delivery(delivery_method, options={})
args = @mailer.name, @mail_method.to_s, delivery_method.to_s, *@args
- set_options = {}
- set_options[:wait_until] = options[:at] if options[:at]
- set_options[:wait] = options[:in] if options[:in]
- ActionMailer::DeliveryJob.set(set_options).perform_later(*args)
+ ActionMailer::DeliveryJob.set(options).perform_later(*args)
end
end
end
diff --git a/actionmailer/test/message_delivery_test.rb b/actionmailer/test/message_delivery_test.rb
index db1e3c830c..9abf8b225c 100644
--- a/actionmailer/test/message_delivery_test.rb
+++ b/actionmailer/test/message_delivery_test.rb
@@ -87,15 +87,17 @@ class MessageDeliveryTest < ActiveSupport::TestCase
end
test 'should enqueue a delivery with a delay' do
- assert_performed_with(job: ActionMailer::DeliveryJob, args: ['DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3]) do
- @mail.deliver_later in: 600.seconds
+ travel_to Time.new(2004, 11, 24, 01, 04, 44) do
+ assert_performed_with(job: ActionMailer::DeliveryJob, at: Time.current.to_f+600.seconds, args: ['DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3]) do
+ @mail.deliver_later wait: 600.seconds
+ end
end
end
test 'should enqueue a delivery at a specific time' do
later_time = Time.now.to_f + 3600
assert_performed_with(job: ActionMailer::DeliveryJob, at: later_time, args: ['DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3]) do
- @mail.deliver_later at: later_time
+ @mail.deliver_later wait_until: later_time
end
end
diff --git a/activejob/lib/active_job/configured_job.rb b/activejob/lib/active_job/configured_job.rb
index 61efc9b09e..979280b910 100644
--- a/activejob/lib/active_job/configured_job.rb
+++ b/activejob/lib/active_job/configured_job.rb
@@ -2,8 +2,6 @@ module ActiveJob
class ConfiguredJob #:nodoc:
def initialize(job_class, options={})
@options = options
- @options[:in] = @options.delete(:wait) if @options[:wait]
- @options[:at] = @options.delete(:wait_until) if @options[:wait_until]
@job_class = job_class
end
diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb
index 32453930cc..e8bc44cbc4 100644
--- a/activejob/lib/active_job/enqueuing.rb
+++ b/activejob/lib/active_job/enqueuing.rb
@@ -27,8 +27,8 @@ module ActiveJob
# you can ask Active Job to retry performing your job.
#
# ==== Options
- # * <tt>:in</tt> - Enqueues the job with the specified delay
- # * <tt>:at</tt> - Enqueues the job at the time specified
+ # * <tt>:wait</tt> - Enqueues the job with the specified delay
+ # * <tt>:wait_until</tt> - Enqueues the job at the time specified
# * <tt>:queue</tt> - Enqueues the job on the specified queue
#
# ==== Examples
@@ -48,19 +48,19 @@ module ActiveJob
# Equeue the job to be performed by the queue adapter.
#
# ==== Options
- # * <tt>:in</tt> - Enqueues the job with the specified delay
- # * <tt>:at</tt> - Enqueues the job at the time specified
+ # * <tt>:wait</tt> - Enqueues the job with the specified delay
+ # * <tt>:wait_until</tt> - Enqueues the job at the time specified
# * <tt>:queue</tt> - Enqueues the job on the specified queue
#
# ==== Examples
#
# my_job_instance.enqueue
- # my_job_instance.enqueue in: 5.minutes
+ # my_job_instance.enqueue wait: 5.minutes
# my_job_instance.enqueue queue: :important
- # my_job_instance.enqueue at: Date.tomorrow.midnight
+ # my_job_instance.enqueue wait_until: Date.tomorrow.midnight
def enqueue(options={})
- self.scheduled_at = options[:in].seconds.from_now.to_f if options[:in]
- self.scheduled_at = options[:at].to_f if options[:at]
+ 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.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
run_callbacks :enqueue do
if self.scheduled_at