mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #1247 from beauby/jsonapi-toplevel-links
Add support for toplevel JSON API links.
This commit is contained in:
32
test/adapter/json_api/links_test.rb
Normal file
32
test/adapter/json_api/links_test.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
module Adapter
|
||||
class JsonApi
|
||||
class LinksTest < Minitest::Test
|
||||
def setup
|
||||
@post = Post.new(id: 1337, comments: [], author: nil)
|
||||
end
|
||||
|
||||
def test_toplevel_links
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
@post,
|
||||
adapter: :json_api,
|
||||
links: {
|
||||
self: {
|
||||
href: '//posts'
|
||||
}
|
||||
}).serializable_hash
|
||||
expected = {
|
||||
self: {
|
||||
href: '//posts'
|
||||
}
|
||||
}
|
||||
assert_equal(expected, hash[:links])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user