mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Job payload should be symmetric across JSON dump/load
Placing non-native JSON data types, like symbols, in the hash to serialize means that the deserialize method will return something different from what was serialized, a common bug and source of frustration for devs.
This commit is contained in:
parent
5cd2beb013
commit
702ef37767
2 changed files with 4 additions and 4 deletions
|
@ -79,7 +79,7 @@ module ActiveJob
|
|||
'queue_name' => queue_name,
|
||||
'priority' => priority,
|
||||
'arguments' => serialize_arguments(arguments),
|
||||
'locale' => I18n.locale
|
||||
'locale' => I18n.locale.to_s
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ class JobSerializationTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test 'serialize includes current locale' do
|
||||
assert_equal :en, HelloJob.new.serialize['locale']
|
||||
assert_equal 'en', HelloJob.new.serialize['locale']
|
||||
end
|
||||
|
||||
test 'deserialize sets locale' do
|
||||
job = HelloJob.new
|
||||
job.deserialize 'locale' => :es
|
||||
assert_equal :es, job.locale
|
||||
job.deserialize 'locale' => 'es'
|
||||
assert_equal 'es', job.locale
|
||||
end
|
||||
|
||||
test 'deserialize sets default locale' do
|
||||
|
|
Loading…
Reference in a new issue