aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/cases/argument_serialization_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 18:41:18 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 18:41:18 +0200
commitbde6547bb6a8ddf18fb687bf20893d3dc87e0358 (patch)
tree549bb6e0b876050f688453aaae9d3e03d65e0a34 /activejob/test/cases/argument_serialization_test.rb
parent93c9534c9871d4adad4bc33b5edc355672b59c61 (diff)
downloadrails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.tar.gz
rails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.tar.bz2
rails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.zip
applies new string literal convention in activejob/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'activejob/test/cases/argument_serialization_test.rb')
-rw-r--r--activejob/test/cases/argument_serialization_test.rb48
1 files changed, 24 insertions, 24 deletions
diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb
index 75b06ebde4..af3d4f2a8e 100644
--- a/activejob/test/cases/argument_serialization_test.rb
+++ b/activejob/test/cases/argument_serialization_test.rb
@@ -1,25 +1,25 @@
-require 'helper'
-require 'active_job/arguments'
-require 'models/person'
-require 'active_support/core_ext/hash/indifferent_access'
-require 'jobs/kwargs_job'
+require "helper"
+require "active_job/arguments"
+require "models/person"
+require "active_support/core_ext/hash/indifferent_access"
+require "jobs/kwargs_job"
class ArgumentSerializationTest < ActiveSupport::TestCase
setup do
- @person = Person.find('5')
+ @person = Person.find("5")
end
[ nil, 1, 1.0, 1_000_000_000_000_000_000_000,
- 'a', true, false, BigDecimal.new(5),
- [ 1, 'a' ],
- { 'a' => 1 }
+ "a", true, false, BigDecimal.new(5),
+ [ 1, "a" ],
+ { "a" => 1 }
].each do |arg|
test "serializes #{arg.class} - #{arg} verbatim" do
assert_arguments_unchanged arg
end
end
- [ :a, Object.new, self, Person.find('5').to_gid ].each do |arg|
+ [ :a, Object.new, self, Person.find("5").to_gid ].each do |arg|
test "does not serialize #{arg.class}" do
assert_raises ActiveJob::SerializationError do
ActiveJob::Arguments.serialize [ arg ]
@@ -31,22 +31,22 @@ class ArgumentSerializationTest < ActiveSupport::TestCase
end
end
- test 'should convert records to Global IDs' do
+ test "should convert records to Global IDs" do
assert_arguments_roundtrip [@person]
end
- test 'should dive deep into arrays and hashes' do
+ test "should dive deep into arrays and hashes" do
assert_arguments_roundtrip [3, [@person]]
- assert_arguments_roundtrip [{ 'a' => @person }]
+ assert_arguments_roundtrip [{ "a" => @person }]
end
- test 'should maintain string and symbol keys' do
+ test "should maintain string and symbol keys" do
assert_arguments_roundtrip([a: 1, "b" => 2])
end
- test 'should maintain hash with indifferent access' do
+ test "should maintain hash with indifferent access" do
symbol_key = { a: 1 }
- string_key = { 'a' => 1 }
+ string_key = { "a" => 1 }
indifferent_access = { a: 1 }.with_indifferent_access
assert_not_instance_of ActiveSupport::HashWithIndifferentAccess, perform_round_trip([symbol_key]).first
@@ -54,7 +54,7 @@ class ArgumentSerializationTest < ActiveSupport::TestCase
assert_instance_of ActiveSupport::HashWithIndifferentAccess, perform_round_trip([indifferent_access]).first
end
- test 'should disallow non-string/symbol hash keys' do
+ test "should disallow non-string/symbol hash keys" do
assert_raises ActiveJob::SerializationError do
ActiveJob::Arguments.serialize [ { 1 => 2 } ]
end
@@ -64,16 +64,16 @@ class ArgumentSerializationTest < ActiveSupport::TestCase
end
end
- test 'should not allow reserved hash keys' do
- ['_aj_globalid', :_aj_globalid, '_aj_symbol_keys', :_aj_symbol_keys,
- '_aj_hash_with_indifferent_access', :_aj_hash_with_indifferent_access].each do |key|
+ test "should not allow reserved hash keys" do
+ ["_aj_globalid", :_aj_globalid, "_aj_symbol_keys", :_aj_symbol_keys,
+ "_aj_hash_with_indifferent_access", :_aj_hash_with_indifferent_access].each do |key|
assert_raises ActiveJob::SerializationError do
ActiveJob::Arguments.serialize [key => 1]
end
end
end
- test 'should not allow non-primitive objects' do
+ test "should not allow non-primitive objects" do
assert_raises ActiveJob::SerializationError do
ActiveJob::Arguments.serialize [Object.new]
end
@@ -83,17 +83,17 @@ class ArgumentSerializationTest < ActiveSupport::TestCase
end
end
- test 'allows for keyword arguments' do
+ test "allows for keyword arguments" do
KwargsJob.perform_later(argument: 2)
assert_equal "Job with argument: 2", JobBuffer.last_value
end
- test 'raises a friendly SerializationError for records without ids' do
+ test "raises a friendly SerializationError for records without ids" do
err = assert_raises ActiveJob::SerializationError do
ActiveJob::Arguments.serialize [Person.new(nil)]
end
- assert_match 'Unable to serialize Person without an id.', err.message
+ assert_match "Unable to serialize Person without an id.", err.message
end
private