aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
Diffstat (limited to 'activejob')
-rw-r--r--activejob/lib/active_job/arguments.rb10
-rw-r--r--activejob/lib/active_job/queue_adapters/test_adapter.rb1
-rw-r--r--activejob/test/cases/rescue_test.rb5
3 files changed, 11 insertions, 5 deletions
diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb
index e54f4afbc7..9d4490b0fc 100644
--- a/activejob/lib/active_job/arguments.rb
+++ b/activejob/lib/active_job/arguments.rb
@@ -5,7 +5,7 @@ module ActiveJob
class DeserializationError < StandardError
attr_reader :original_exception
- def initialize(e)
+ def initialize(e) #:nodoc:
super ("Error while trying to deserialize arguments: #{e.message}")
@original_exception = e
set_backtrace e.backtrace
@@ -30,6 +30,8 @@ module ActiveJob
def deserialize(arguments)
arguments.map { |argument| deserialize_argument(argument) }
+ rescue => e
+ raise DeserializationError.new(e)
end
private
@@ -40,7 +42,7 @@ module ActiveJob
when *TYPE_WHITELIST
argument
when Array
- serialize(argument)
+ argument.map { |arg| serialize_argument(arg) }
when Hash
Hash[ argument.map { |key, value| [ serialize_hash_key(key), serialize_argument(value) ] } ]
else
@@ -51,14 +53,12 @@ module ActiveJob
def deserialize_argument(argument)
case argument
when Array
- deserialize(argument)
+ argument.map { |arg| deserialize_argument(arg) }
when Hash
Hash[ argument.map { |key, value| [ key, deserialize_argument(value) ] } ].with_indifferent_access
else
GlobalID::Locator.locate(argument) || argument
end
- rescue => e
- raise DeserializationError.new(e)
end
def serialize_hash_key(key)
diff --git a/activejob/lib/active_job/queue_adapters/test_adapter.rb b/activejob/lib/active_job/queue_adapters/test_adapter.rb
index 971db9d7de..185d6fc7e6 100644
--- a/activejob/lib/active_job/queue_adapters/test_adapter.rb
+++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb
@@ -3,6 +3,7 @@ module ActiveJob
class TestAdapter
attr_accessor(:perform_enqueued_jobs) { false }
attr_accessor(:perform_enqueued_at_jobs) { false }
+ delegate :name, to: :class
# Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
def enqueued_jobs
diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb
index d9ea3c91d7..3af147383e 100644
--- a/activejob/test/cases/rescue_test.rb
+++ b/activejob/test/cases/rescue_test.rb
@@ -28,4 +28,9 @@ class RescueTest < ActiveSupport::TestCase
assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound'
assert_not_includes JobBuffer.values, 'performed beautifully'
end
+
+ test "should not wrap DeserializationError in DeserializationError" do
+ RescueJob.enqueue [Person.new(404)]
+ assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound'
+ end
end