mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Fix test bug found by assert_nil
This commit is contained in:
parent
6acb4055c9
commit
4dfbe2747b
@ -146,25 +146,25 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_node_not_included_when_no_link
|
def test_node_not_included_when_no_link
|
||||||
expected = nil
|
expected = { meta: {} }
|
||||||
assert_relationship(:unlinked_tags, expected)
|
assert_relationship(:unlinked_tags, expected, key_transform: :unaltered)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def assert_relationship(relationship_name, expected, opts = {})
|
||||||
|
actual = relationship_data(relationship_name, opts)
|
||||||
|
assert_equal(expected, actual)
|
||||||
|
end
|
||||||
|
|
||||||
def result(opts)
|
def result(opts)
|
||||||
opts = { adapter: :json_api }.merge(opts)
|
opts = { adapter: :json_api }.merge(opts)
|
||||||
serializable(@author, opts).serializable_hash
|
serializable(@author, opts).serializable_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_relationship(relationship_name, expected, opts = {})
|
def relationship_data(relationship_name, opts = {})
|
||||||
hash = result(opts)
|
hash = result(opts)
|
||||||
actual = hash[:data][:relationships][relationship_name]
|
hash[:data][:relationships][relationship_name]
|
||||||
if expected.nil?
|
|
||||||
assert_nil(actual)
|
|
||||||
else
|
|
||||||
assert_equal(expected, actual)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user