Skip to content

Commit 37e4f1c

Browse files
committed
Update top-level link with PR #1247
update according rubocop rules
1 parent 1844c16 commit 37e4f1c

File tree

4 files changed

+15
-133
lines changed

4 files changed

+15
-133
lines changed

lib/active_model/serializer/adapter/json_api/links.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/action_controller/serialization_test.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ def render_array_using_implicit_serializer_and_meta
4747

4848
def render_array_using_implicit_serializer_and_links
4949
with_adapter ActiveModel::Serializer::Adapter::JsonApi do
50-
5150
@profiles = [
52-
Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
51+
Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
5352
]
5453

55-
render json: @profiles, links: { self: "http://example.com/api/profiles/1" }
54+
render json: @profiles, links: { self: 'http://example.com/api/profiles/1' }
5655
end
5756
end
5857

@@ -272,15 +271,15 @@ def test_render_array_using_implicit_serializer_and_links
272271
data: [
273272
{
274273
id: assigns(:profiles).first.id.to_s,
275-
type: "profiles",
274+
type: 'profiles',
276275
attributes: {
277-
name: "Name 1",
278-
description: "Description 1"
276+
name: 'Name 1',
277+
description: 'Description 1'
279278
}
280279
}
281280
],
282281
links: {
283-
self: "http://example.com/api/profiles/1"
282+
self: 'http://example.com/api/profiles/1'
284283
}
285284
}
286285

test/adapter/json_api/links_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ def test_toplevel_links
4747
assert_equal(expected, hash[:links])
4848
end
4949

50+
def test_nil_toplevel_links
51+
hash = ActiveModel::SerializableResource.new(
52+
@post,
53+
adapter: :json_api,
54+
links: nil
55+
).serializable_hash
56+
assert_equal(nil, hash[:links])
57+
end
58+
5059
def test_resource_links
5160
hash = serializable(@author, adapter: :json_api).serializable_hash
5261
expected = {

test/adapter/json_api/top_level_links_test.rb

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)