test/unit/serializer/serializer_test.rb in jsonapi-resources-0.5.5 vs test/unit/serializer/serializer_test.rb in jsonapi-resources-0.5.6
- old
+ new
@@ -962,10 +962,11 @@
]
},
JSONAPI::ResourceSerializer.new(PostResource,
include: ['comments', 'comments.tags']).serialize_to_hash(posts)
)
+ ensure
JSONAPI.configuration.always_include_to_one_linkage_data = false
end
def test_serializer_array_of_resources
@@ -1408,13 +1409,10 @@
}).serialize_to_hash(posts)
)
end
def test_serializer_camelized_with_value_formatters
- # JSONAPI.configuration.json_key_format = :camelized_key
- # JSONAPI.configuration.route_format = :camelized_route
-
assert_hash_equals(
{
data: {
type: 'expenseEntries',
id: '1',
@@ -1616,10 +1614,11 @@
]
}, planet_hash)
end
def test_serializer_booleans
+ original_config = JSONAPI.configuration.dup
JSONAPI.configuration.json_key_format = :underscored_key
preferences = PreferencesResource.new(Preferences.find(1))
assert_hash_equals(
@@ -1649,13 +1648,16 @@
}
}
},
JSONAPI::ResourceSerializer.new(PreferencesResource).serialize_to_hash(preferences)
)
+ ensure
+ JSONAPI.configuration = original_config
end
def test_serializer_data_types
+ original_config = JSONAPI.configuration.dup
JSONAPI.configuration.json_key_format = :underscored_key
facts = FactResource.new(Fact.find(1))
assert_hash_equals(
@@ -1679,9 +1681,11 @@
}
}
},
JSONAPI::ResourceSerializer.new(FactResource).serialize_to_hash(facts)
)
+ ensure
+ JSONAPI.configuration = original_config
end
def test_serializer_to_one
serialized = JSONAPI::ResourceSerializer.new(
Api::V5::AuthorResource,