mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
return nil if id is nil
This commit is contained in:
@@ -36,6 +36,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_relationship_with_nil_model_and_belongs_to_id_on_self
|
||||
original_config = ActiveModelSerializers.config.jsonapi_use_foreign_key_on_belongs_to_relationship
|
||||
ActiveModelSerializers.config.jsonapi_use_foreign_key_on_belongs_to_relationship = true
|
||||
|
||||
expected = { data: nil }
|
||||
@@ -46,7 +47,10 @@ module ActiveModelSerializers
|
||||
actual = build_serializer_and_serialize_relationship(model, relationship_name) do
|
||||
belongs_to :blog
|
||||
end
|
||||
|
||||
assert_equal(expected, actual)
|
||||
ensure
|
||||
ActiveModelSerializers.config.jsonapi_use_foreign_key_on_belongs_to_relationship = original_config
|
||||
end
|
||||
|
||||
def test_relationship_with_data_array
|
||||
|
||||
@@ -147,8 +147,7 @@ module ActiveModelSerializers
|
||||
def test_for_type_with_id_given_blank_id
|
||||
id = ''
|
||||
actual = ResourceIdentifier.for_type_with_id('admin_user', id, {})
|
||||
expected = { type: 'admin-users' }
|
||||
assert_equal actual, expected
|
||||
assert_nil actual
|
||||
end
|
||||
|
||||
def test_for_type_with_id_inflected
|
||||
|
||||
Reference in New Issue
Block a user