active_model_serializers 0.10.0.rc2 → 0.10.0.rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +82 -0
  4. data/.rubocop_todo.yml +315 -0
  5. data/.simplecov +99 -0
  6. data/.travis.yml +8 -0
  7. data/CHANGELOG.md +9 -3
  8. data/Gemfile +39 -8
  9. data/README.md +55 -31
  10. data/Rakefile +29 -2
  11. data/active_model_serializers.gemspec +37 -13
  12. data/appveyor.yml +25 -0
  13. data/docs/README.md +29 -0
  14. data/docs/general/adapters.md +110 -0
  15. data/docs/general/configuration_options.md +11 -0
  16. data/docs/general/getting_started.md +73 -0
  17. data/docs/howto/add_pagination_links.md +112 -0
  18. data/docs/howto/add_root_key.md +51 -0
  19. data/docs/howto/outside_controller_use.md +42 -0
  20. data/lib/action_controller/serialization.rb +24 -33
  21. data/lib/active_model/serializable_resource.rb +70 -0
  22. data/lib/active_model/serializer.rb +50 -131
  23. data/lib/active_model/serializer/adapter.rb +84 -21
  24. data/lib/active_model/serializer/adapter/flatten_json.rb +9 -9
  25. data/lib/active_model/serializer/adapter/fragment_cache.rb +10 -13
  26. data/lib/active_model/serializer/adapter/json.rb +25 -28
  27. data/lib/active_model/serializer/adapter/json/fragment_cache.rb +2 -12
  28. data/lib/active_model/serializer/adapter/json_api.rb +100 -98
  29. data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +4 -14
  30. data/lib/active_model/serializer/adapter/json_api/pagination_links.rb +50 -0
  31. data/lib/active_model/serializer/adapter/null.rb +2 -8
  32. data/lib/active_model/serializer/array_serializer.rb +22 -17
  33. data/lib/active_model/serializer/association.rb +20 -0
  34. data/lib/active_model/serializer/associations.rb +97 -0
  35. data/lib/active_model/serializer/belongs_to_reflection.rb +10 -0
  36. data/lib/active_model/serializer/collection_reflection.rb +7 -0
  37. data/lib/active_model/serializer/configuration.rb +1 -0
  38. data/lib/active_model/serializer/fieldset.rb +7 -7
  39. data/lib/active_model/serializer/has_many_reflection.rb +10 -0
  40. data/lib/active_model/serializer/has_one_reflection.rb +10 -0
  41. data/lib/active_model/serializer/lint.rb +129 -0
  42. data/lib/active_model/serializer/railtie.rb +7 -0
  43. data/lib/active_model/serializer/reflection.rb +74 -0
  44. data/lib/active_model/serializer/singular_reflection.rb +7 -0
  45. data/lib/active_model/serializer/utils.rb +35 -0
  46. data/lib/active_model/serializer/version.rb +1 -1
  47. data/lib/active_model_serializers.rb +28 -14
  48. data/lib/generators/serializer/serializer_generator.rb +7 -7
  49. data/lib/generators/serializer/templates/{serializer.rb → serializer.rb.erb} +2 -2
  50. data/lib/tasks/rubocop.rake +0 -0
  51. data/test/action_controller/adapter_selector_test.rb +3 -3
  52. data/test/action_controller/explicit_serializer_test.rb +9 -9
  53. data/test/action_controller/json_api/linked_test.rb +179 -0
  54. data/test/action_controller/json_api/pagination_test.rb +116 -0
  55. data/test/action_controller/serialization_scope_name_test.rb +10 -6
  56. data/test/action_controller/serialization_test.rb +149 -112
  57. data/test/active_record_test.rb +9 -0
  58. data/test/adapter/fragment_cache_test.rb +11 -1
  59. data/test/adapter/json/belongs_to_test.rb +4 -5
  60. data/test/adapter/json/collection_test.rb +30 -21
  61. data/test/adapter/json/has_many_test.rb +20 -9
  62. data/test/adapter/json_api/belongs_to_test.rb +38 -38
  63. data/test/adapter/json_api/collection_test.rb +22 -23
  64. data/test/adapter/json_api/has_many_embed_ids_test.rb +2 -2
  65. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +4 -4
  66. data/test/adapter/json_api/has_many_test.rb +54 -19
  67. data/test/adapter/json_api/has_one_test.rb +28 -8
  68. data/test/adapter/json_api/json_api_test.rb +37 -0
  69. data/test/adapter/json_api/linked_test.rb +75 -75
  70. data/test/adapter/json_api/pagination_links_test.rb +115 -0
  71. data/test/adapter/json_api/resource_type_config_test.rb +59 -0
  72. data/test/adapter/json_test.rb +18 -5
  73. data/test/adapter_test.rb +10 -11
  74. data/test/array_serializer_test.rb +63 -5
  75. data/test/capture_warnings.rb +65 -0
  76. data/test/fixtures/active_record.rb +56 -0
  77. data/test/fixtures/poro.rb +60 -29
  78. data/test/generators/scaffold_controller_generator_test.rb +1 -2
  79. data/test/generators/serializer_generator_test.rb +17 -12
  80. data/test/lint_test.rb +37 -0
  81. data/test/logger_test.rb +18 -0
  82. data/test/poro_test.rb +9 -0
  83. data/test/serializable_resource_test.rb +27 -0
  84. data/test/serializers/adapter_for_test.rb +123 -3
  85. data/test/serializers/association_macros_test.rb +36 -0
  86. data/test/serializers/associations_test.rb +70 -47
  87. data/test/serializers/attribute_test.rb +28 -4
  88. data/test/serializers/attributes_test.rb +8 -14
  89. data/test/serializers/cache_test.rb +58 -31
  90. data/test/serializers/fieldset_test.rb +3 -4
  91. data/test/serializers/meta_test.rb +42 -28
  92. data/test/serializers/root_test.rb +21 -0
  93. data/test/serializers/serializer_for_test.rb +1 -1
  94. data/test/support/rails_app.rb +21 -0
  95. data/test/support/serialization_testing.rb +13 -0
  96. data/test/support/simplecov.rb +6 -0
  97. data/test/support/stream_capture.rb +50 -0
  98. data/test/support/test_case.rb +5 -0
  99. data/test/test_helper.rb +41 -29
  100. data/test/utils/include_args_to_hash_test.rb +79 -0
  101. metadata +123 -17
  102. data/test/action_controller/json_api_linked_test.rb +0 -179
  103. data/test/action_controller/rescue_from_test.rb +0 -32
  104. data/test/serializers/urls_test.rb +0 -26
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class ActiveRecordTest < Minitest::Test
4
+ include ActiveModel::Serializer::Lint::Tests
5
+
6
+ def setup
7
+ @resource = ARModels::Post.new
8
+ end
9
+ end
@@ -4,11 +4,14 @@ module ActiveModel
4
4
  class Adapter
5
5
  class FragmentCacheTest < Minitest::Test
6
6
  def setup
7
+ @spam = Spam::UnrelatedLink.new(id: 'spam-id-1')
7
8
  @author = Author.new(name: 'Joao M. D. Moura')
8
- @role = Role.new(name: 'Great Author', description:nil)
9
+ @role = Role.new(name: 'Great Author', description: nil)
9
10
  @role.author = [@author]
10
11
  @role_serializer = RoleSerializer.new(@role)
12
+ @spam_serializer = Spam::UnrelatedLinkSerializer.new(@spam)
11
13
  @role_hash = FragmentCache.new(RoleSerializer.adapter.new(@role_serializer), @role_serializer, {})
14
+ @spam_hash = FragmentCache.new(Spam::UnrelatedLinkSerializer.adapter.new(@spam_serializer), @spam_serializer, {})
12
15
  end
13
16
 
14
17
  def test_fragment_fetch_with_virtual_attributes
@@ -20,6 +23,13 @@ module ActiveModel
20
23
  }
21
24
  assert_equal(@role_hash.fetch, expected_result)
22
25
  end
26
+
27
+ def test_fragment_fetch_with_namespaced_object
28
+ expected_result = {
29
+ id: @spam.id
30
+ }
31
+ assert_equal(@spam_hash.fetch, expected_result)
32
+ end
23
33
  end
24
34
  end
25
35
  end
@@ -11,11 +11,10 @@ module ActiveModel
11
11
  @comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
12
12
  @post.comments = [@comment]
13
13
  @anonymous_post.comments = []
14
- @post.author = @author
15
14
  @comment.post = @post
16
15
  @comment.author = nil
17
16
  @anonymous_post.author = nil
18
- @blog = Blog.new(id: 1, name: "My Blog!!")
17
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
19
18
  @post.blog = @blog
20
19
  @anonymous_post.blog = nil
21
20
 
@@ -25,21 +24,21 @@ module ActiveModel
25
24
  end
26
25
 
27
26
  def test_includes_post
28
- assert_equal({id: 42, title: 'New Post', body: 'Body'}, @adapter.serializable_hash[:comment][:post])
27
+ assert_equal({ id: 42, title: 'New Post', body: 'Body' }, @adapter.serializable_hash[:comment][:post])
29
28
  end
30
29
 
31
30
  def test_include_nil_author
32
31
  serializer = PostSerializer.new(@anonymous_post)
33
32
  adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
34
33
 
35
- assert_equal({post: {title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], blog: {id: 999, name: "Custom blog"}, author: nil}}, adapter.serializable_hash)
34
+ assert_equal({ post: { title: 'Hello!!', body: 'Hello, world!!', id: 43, comments: [], blog: { id: 999, name: 'Custom blog' }, author: nil } }, adapter.serializable_hash)
36
35
  end
37
36
 
38
37
  def test_include_nil_author_with_specified_serializer
39
38
  serializer = PostPreviewSerializer.new(@anonymous_post)
40
39
  adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
41
40
 
42
- assert_equal({posts: {title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], author: nil}}, adapter.serializable_hash)
41
+ assert_equal({ post: { title: 'Hello!!', body: 'Hello, world!!', id: 43, comments: [], author: nil } }, adapter.serializable_hash)
43
42
  end
44
43
  end
45
44
  end
@@ -13,58 +13,67 @@ module ActiveModel
13
13
  @second_post.comments = []
14
14
  @first_post.author = @author
15
15
  @second_post.author = @author
16
- @blog = Blog.new(id: 1, name: "My Blog!!")
16
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
17
17
  @first_post.blog = @blog
18
18
  @second_post.blog = nil
19
19
 
20
- @serializer = ArraySerializer.new([@first_post, @second_post])
21
- @adapter = ActiveModel::Serializer::Adapter::Json.new(@serializer)
22
20
  ActionController::Base.cache_store.clear
23
21
  end
24
22
 
25
23
  def test_with_serializer_option
26
- @blog.special_attribute = "Special"
24
+ @blog.special_attribute = 'Special'
27
25
  @blog.articles = [@first_post, @second_post]
28
- @serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
29
- @adapter = ActiveModel::Serializer::Adapter::Json.new(@serializer)
26
+ serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
27
+ adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
30
28
 
31
- expected = {custom_blogs:[{
29
+ expected = { blogs: [{
32
30
  id: 1,
33
- special_attribute: "Special",
34
- articles: [{id: 1,title: "Hello!!", body: "Hello, world!!"}, {id: 2, title: "New Post", body: "Body"}]
35
- }]}
36
- assert_equal expected, @adapter.serializable_hash
31
+ special_attribute: 'Special',
32
+ articles: [{ id: 1, title: 'Hello!!', body: 'Hello, world!!' }, { id: 2, title: 'New Post', body: 'Body' }]
33
+ }] }
34
+ assert_equal expected, adapter.serializable_hash
37
35
  end
38
36
 
39
37
  def test_include_multiple_posts
38
+ serializer = ArraySerializer.new([@first_post, @second_post])
39
+ adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
40
+
40
41
  expected = { posts: [{
41
- title: "Hello!!",
42
- body: "Hello, world!!",
42
+ title: 'Hello!!',
43
+ body: 'Hello, world!!',
43
44
  id: 1,
44
45
  comments: [],
45
46
  author: {
46
47
  id: 1,
47
- name: "Steve K."
48
+ name: 'Steve K.'
48
49
  },
49
50
  blog: {
50
51
  id: 999,
51
- name: "Custom blog"
52
+ name: 'Custom blog'
52
53
  }
53
54
  }, {
54
- title: "New Post",
55
- body: "Body",
55
+ title: 'New Post',
56
+ body: 'Body',
56
57
  id: 2,
57
58
  comments: [],
58
59
  author: {
59
60
  id: 1,
60
- name: "Steve K."
61
+ name: 'Steve K.'
61
62
  },
62
63
  blog: {
63
64
  id: 999,
64
- name: "Custom blog"
65
+ name: 'Custom blog'
65
66
  }
66
- }]}
67
- assert_equal expected, @adapter.serializable_hash
67
+ }] }
68
+ assert_equal expected, adapter.serializable_hash
69
+ end
70
+
71
+ def test_root_is_underscored
72
+ virtual_value = VirtualValue.new(id: 1)
73
+ serializer = ArraySerializer.new([virtual_value])
74
+ adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
75
+
76
+ assert_equal 1, adapter.serializable_hash[:virtual_values].length
68
77
  end
69
78
  end
70
79
  end
@@ -8,29 +8,40 @@ module ActiveModel
8
8
  def setup
9
9
  ActionController::Base.cache_store.clear
10
10
  @author = Author.new(id: 1, name: 'Steve K.')
11
- @post = Post.new(title: 'New Post', body: 'Body')
11
+ @post = Post.new(id: 42, title: 'New Post', body: 'Body')
12
12
  @first_comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
13
13
  @second_comment = Comment.new(id: 2, body: 'ZOMG ANOTHER COMMENT')
14
14
  @post.comments = [@first_comment, @second_comment]
15
15
  @post.author = @author
16
16
  @first_comment.post = @post
17
17
  @second_comment.post = @post
18
- @blog = Blog.new(id: 1, name: "My Blog!!")
18
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
19
19
  @post.blog = @blog
20
-
21
- @serializer = PostSerializer.new(@post)
22
- @adapter = ActiveModel::Serializer::Adapter::Json.new(@serializer)
20
+ @tag = Tag.new(id: 1, name: '#hash_tag')
21
+ @post.tags = [@tag]
23
22
  end
24
23
 
25
24
  def test_has_many
25
+ serializer = PostSerializer.new(@post)
26
+ adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
26
27
  assert_equal([
27
- {id: 1, body: 'ZOMG A COMMENT'},
28
- {id: 2, body: 'ZOMG ANOTHER COMMENT'}
29
- ], @adapter.serializable_hash[:post][:comments])
28
+ { id: 1, body: 'ZOMG A COMMENT' },
29
+ { id: 2, body: 'ZOMG ANOTHER COMMENT' }
30
+ ], adapter.serializable_hash[:post][:comments])
31
+ end
32
+
33
+ def test_has_many_with_no_serializer
34
+ serializer = PostWithTagsSerializer.new(@post)
35
+ adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
36
+ assert_equal({
37
+ id: 42,
38
+ tags: [
39
+ { 'attributes' => { 'id' => 1, 'name' => '#hash_tag' } }
40
+ ]
41
+ }.to_json, adapter.serializable_hash[:post].to_json)
30
42
  end
31
43
  end
32
44
  end
33
45
  end
34
46
  end
35
47
  end
36
-
@@ -21,7 +21,7 @@ module ActiveModel
21
21
  @comment.author = nil
22
22
  @post.author = @author
23
23
  @anonymous_post.author = nil
24
- @blog = Blog.new(id: 1, name: "My Blog!!")
24
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
25
25
  @blog.writer = @author
26
26
  @blog.articles = [@post, @anonymous_post]
27
27
  @author.posts = []
@@ -32,41 +32,41 @@ module ActiveModel
32
32
  end
33
33
 
34
34
  def test_includes_post_id
35
- expected = { data: { type: "posts", id: "42" } }
35
+ expected = { data: { type: 'posts', id: '42' } }
36
36
 
37
37
  assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:post])
38
38
  end
39
39
 
40
40
  def test_includes_linked_post
41
- @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'post')
41
+ @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: [:post])
42
42
  expected = [{
43
- id: "42",
44
- type: "posts",
43
+ id: '42',
44
+ type: 'posts',
45
45
  attributes: {
46
46
  title: 'New Post',
47
47
  body: 'Body',
48
48
  },
49
49
  relationships: {
50
- comments: { data: [ { type: "comments", id: "1" } ] },
51
- blog: { data: { type: "blogs", id: "999" } },
52
- author: { data: { type: "authors", id: "1" } }
50
+ comments: { data: [{ type: 'comments', id: '1' }] },
51
+ blog: { data: { type: 'blogs', id: '999' } },
52
+ author: { data: { type: 'authors', id: '1' } }
53
53
  }
54
54
  }]
55
55
  assert_equal expected, @adapter.serializable_hash[:included]
56
56
  end
57
57
 
58
58
  def test_limiting_linked_post_fields
59
- @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'post', fields: {post: [:title]})
59
+ @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: [:post], fields: { post: [:title] })
60
60
  expected = [{
61
- id: "42",
62
- type: "posts",
61
+ id: '42',
62
+ type: 'posts',
63
63
  attributes: {
64
64
  title: 'New Post'
65
65
  },
66
66
  relationships: {
67
- comments: { data: [ { type: "comments", id: "1" } ] },
68
- blog: { data: { type: "blogs", id: "999" } },
69
- author: { data: { type: "authors", id: "1" } }
67
+ comments: { data: [{ type: 'comments', id: '1' }] },
68
+ blog: { data: { type: 'blogs', id: '999' } },
69
+ author: { data: { type: 'authors', id: '1' } }
70
70
  }
71
71
  }]
72
72
  assert_equal expected, @adapter.serializable_hash[:included]
@@ -76,7 +76,7 @@ module ActiveModel
76
76
  serializer = PostSerializer.new(@anonymous_post)
77
77
  adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
78
78
 
79
- assert_equal({comments: { data: [] }, blog: { data: { type: "blogs", id: "999" } }, author: { data: nil }}, adapter.serializable_hash[:data][:relationships])
79
+ assert_equal({ comments: { data: [] }, blog: { data: { type: 'blogs', id: '999' } }, author: { data: nil } }, adapter.serializable_hash[:data][:relationships])
80
80
  end
81
81
 
82
82
  def test_include_type_for_association_when_different_than_name
@@ -86,19 +86,19 @@ module ActiveModel
86
86
  expected = {
87
87
  writer: {
88
88
  data: {
89
- type: "authors",
90
- id: "1"
89
+ type: 'authors',
90
+ id: '1'
91
91
  }
92
92
  },
93
93
  articles: {
94
94
  data: [
95
95
  {
96
- type: "posts",
97
- id: "42"
96
+ type: 'posts',
97
+ id: '42'
98
98
  },
99
99
  {
100
- type: "posts",
101
- id: "43"
100
+ type: 'posts',
101
+ id: '43'
102
102
  }
103
103
  ]
104
104
  }
@@ -108,42 +108,42 @@ module ActiveModel
108
108
 
109
109
  def test_include_linked_resources_with_type_name
110
110
  serializer = BlogSerializer.new(@blog)
111
- adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer, include: ['writer', 'articles'])
111
+ adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer, include: [:writer, :articles])
112
112
  linked = adapter.serializable_hash[:included]
113
113
  expected = [
114
114
  {
115
- id: "1",
116
- type: "authors",
115
+ id: '1',
116
+ type: 'authors',
117
117
  attributes: {
118
- name: "Steve K."
118
+ name: 'Steve K.'
119
119
  },
120
120
  relationships: {
121
121
  posts: { data: [] },
122
122
  roles: { data: [] },
123
123
  bio: { data: nil }
124
124
  }
125
- },{
126
- id: "42",
127
- type: "posts",
125
+ }, {
126
+ id: '42',
127
+ type: 'posts',
128
128
  attributes: {
129
- title: "New Post",
130
- body: "Body"
129
+ title: 'New Post',
130
+ body: 'Body'
131
131
  },
132
132
  relationships: {
133
- comments: { data: [ { type: "comments", id: "1" } ] },
134
- blog: { data: { type: "blogs", id: "999" } },
135
- author: { data: { type: "authors", id: "1" } }
133
+ comments: { data: [{ type: 'comments', id: '1' }] },
134
+ blog: { data: { type: 'blogs', id: '999' } },
135
+ author: { data: { type: 'authors', id: '1' } }
136
136
  }
137
137
  }, {
138
- id: "43",
139
- type: "posts",
138
+ id: '43',
139
+ type: 'posts',
140
140
  attributes: {
141
- title: "Hello!!",
142
- body: "Hello, world!!"
141
+ title: 'Hello!!',
142
+ body: 'Hello, world!!'
143
143
  },
144
144
  relationships: {
145
145
  comments: { data: [] },
146
- blog: { data: { type: "blogs", id: "999" } },
146
+ blog: { data: { type: 'blogs', id: '999' } },
147
147
  author: { data: nil }
148
148
  }
149
149
  }
@@ -27,29 +27,29 @@ module ActiveModel
27
27
  def test_include_multiple_posts
28
28
  expected = [
29
29
  {
30
- id: "1",
31
- type: "posts",
30
+ id: '1',
31
+ type: 'posts',
32
32
  attributes: {
33
- title: "Hello!!",
34
- body: "Hello, world!!"
33
+ title: 'Hello!!',
34
+ body: 'Hello, world!!'
35
35
  },
36
36
  relationships: {
37
37
  comments: { data: [] },
38
- blog: { data: { type: "blogs", id: "999" } },
39
- author: { data: { type: "authors", id: "1" } }
38
+ blog: { data: { type: 'blogs', id: '999' } },
39
+ author: { data: { type: 'authors', id: '1' } }
40
40
  }
41
41
  },
42
42
  {
43
- id: "2",
44
- type: "posts",
43
+ id: '2',
44
+ type: 'posts',
45
45
  attributes: {
46
- title: "New Post",
47
- body: "Body"
46
+ title: 'New Post',
47
+ body: 'Body'
48
48
  },
49
49
  relationships: {
50
50
  comments: { data: [] },
51
- blog: { data: { type: "blogs", id: "999" } },
52
- author: { data: { type: "authors", id: "1" } }
51
+ blog: { data: { type: 'blogs', id: '999' } },
52
+ author: { data: { type: 'authors', id: '1' } }
53
53
  }
54
54
  }
55
55
  ]
@@ -62,33 +62,32 @@ module ActiveModel
62
62
 
63
63
  expected = [
64
64
  {
65
- id: "1",
66
- type: "posts",
65
+ id: '1',
66
+ type: 'posts',
67
67
  attributes: {
68
- title: "Hello!!"
68
+ title: 'Hello!!'
69
69
  },
70
70
  relationships: {
71
71
  comments: { data: [] },
72
- blog: { data: { type: "blogs", id: "999" } },
73
- author: { data: { type: "authors", id: "1" } }
72
+ blog: { data: { type: 'blogs', id: '999' } },
73
+ author: { data: { type: 'authors', id: '1' } }
74
74
  }
75
75
  },
76
76
  {
77
- id: "2",
78
- type: "posts",
77
+ id: '2',
78
+ type: 'posts',
79
79
  attributes: {
80
- title: "New Post"
80
+ title: 'New Post'
81
81
  },
82
82
  relationships: {
83
83
  comments: { data: [] },
84
- blog: { data: { type: "blogs", id: "999" } },
85
- author: { data: { type: "authors", id: "1" } }
84
+ blog: { data: { type: 'blogs', id: '999' } },
85
+ author: { data: { type: 'authors', id: '1' } }
86
86
  }
87
87
  }
88
88
  ]
89
89
  assert_equal(expected, @adapter.serializable_hash[:data])
90
90
  end
91
-
92
91
  end
93
92
  end
94
93
  end