mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06: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
|
||||
|
||||
def test_node_not_included_when_no_link
|
||||
expected = nil
|
||||
assert_relationship(:unlinked_tags, expected)
|
||||
expected = { meta: {} }
|
||||
assert_relationship(:unlinked_tags, expected, key_transform: :unaltered)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_relationship(relationship_name, expected, opts = {})
|
||||
actual = relationship_data(relationship_name, opts)
|
||||
assert_equal(expected, actual)
|
||||
end
|
||||
|
||||
def result(opts)
|
||||
opts = { adapter: :json_api }.merge(opts)
|
||||
serializable(@author, opts).serializable_hash
|
||||
end
|
||||
|
||||
def assert_relationship(relationship_name, expected, opts = {})
|
||||
def relationship_data(relationship_name, opts = {})
|
||||
hash = result(opts)
|
||||
actual = hash[:data][:relationships][relationship_name]
|
||||
if expected.nil?
|
||||
assert_nil(actual)
|
||||
else
|
||||
assert_equal(expected, actual)
|
||||
end
|
||||
hash[:data][:relationships][relationship_name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user