mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
add failing test and suggestion
This commit is contained in:
parent
339f99fccc
commit
4b0c230d76
@ -55,6 +55,7 @@ module ActiveModelSerializers
|
||||
else
|
||||
association.reflection.type.to_s
|
||||
end
|
||||
# TODO: probably return nil if association.object is nil?
|
||||
ResourceIdentifier.for_type_with_id(type, id, serializable_resource_options)
|
||||
else
|
||||
# TODO(BF): Process relationship without evaluating lazy_association
|
||||
|
||||
@ -35,6 +35,20 @@ module ActiveModelSerializers
|
||||
assert_equal(expected, actual)
|
||||
end
|
||||
|
||||
def test_relationship_with_nil_model_and_belongs_to_id_on_self
|
||||
ActiveModelSerializers.config.jsonapi_use_foreign_key_on_belongs_to_relationship = true
|
||||
|
||||
expected = { data: nil }
|
||||
|
||||
model_attributes = { blog: nil }
|
||||
relationship_name = :blog
|
||||
model = new_model(model_attributes)
|
||||
actual = build_serializer_and_serialize_relationship(model, relationship_name) do
|
||||
belongs_to :blog
|
||||
end
|
||||
assert_equal(expected, actual)
|
||||
end
|
||||
|
||||
def test_relationship_with_data_array
|
||||
expected = {
|
||||
data: [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user