cheap_ams 0.10.5 → 0.10.6

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +49 -0
  3. data/.rubocop_todo.yml +315 -0
  4. data/.simplecov +99 -0
  5. data/.travis.yml +8 -0
  6. data/Gemfile +10 -1
  7. data/README.md +4 -16
  8. data/Rakefile +29 -2
  9. data/cheap_ams.gemspec +3 -2
  10. data/docs/README.md +1 -0
  11. data/docs/general/configuration_options.md +11 -0
  12. data/lib/action_controller/serialization.rb +2 -2
  13. data/lib/active_model/serializable_resource.rb +0 -2
  14. data/lib/active_model/serializer/adapter/fragment_cache.rb +3 -4
  15. data/lib/active_model/serializer/adapter/json/fragment_cache.rb +0 -2
  16. data/lib/active_model/serializer/adapter/json.rb +0 -1
  17. data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +2 -4
  18. data/lib/active_model/serializer/adapter/json_api.rb +87 -93
  19. data/lib/active_model/serializer/adapter.rb +4 -4
  20. data/lib/active_model/serializer/array_serializer.rb +11 -12
  21. data/lib/active_model/serializer/association.rb +0 -1
  22. data/lib/active_model/serializer/fieldset.rb +2 -4
  23. data/lib/active_model/serializer/lint.rb +2 -4
  24. data/lib/active_model/serializer/version.rb +1 -1
  25. data/lib/active_model/serializer.rb +0 -25
  26. data/lib/active_model_serializers.rb +0 -1
  27. data/lib/generators/serializer/serializer_generator.rb +7 -7
  28. data/lib/generators/serializer/templates/{serializer.rb → serializer.rb.erb} +0 -0
  29. data/lib/tasks/rubocop.rake +0 -0
  30. data/test/action_controller/adapter_selector_test.rb +3 -3
  31. data/test/action_controller/explicit_serializer_test.rb +9 -9
  32. data/test/action_controller/json_api/linked_test.rb +28 -28
  33. data/test/action_controller/json_api/pagination_test.rb +24 -24
  34. data/test/action_controller/serialization_test.rb +73 -79
  35. data/test/adapter/fragment_cache_test.rb +2 -2
  36. data/test/adapter/json/belongs_to_test.rb +4 -4
  37. data/test/adapter/json/collection_test.rb +15 -15
  38. data/test/adapter/json/has_many_test.rb +5 -5
  39. data/test/adapter/json_api/belongs_to_test.rb +37 -37
  40. data/test/adapter/json_api/collection_test.rb +22 -23
  41. data/test/adapter/json_api/has_many_embed_ids_test.rb +2 -2
  42. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +4 -4
  43. data/test/adapter/json_api/has_many_test.rb +25 -25
  44. data/test/adapter/json_api/has_one_test.rb +10 -10
  45. data/test/adapter/json_api/json_api_test.rb +6 -7
  46. data/test/adapter/json_api/linked_test.rb +69 -69
  47. data/test/adapter/json_api/pagination_links_test.rb +8 -8
  48. data/test/adapter/json_api/resource_type_config_test.rb +14 -14
  49. data/test/adapter/json_test.rb +7 -7
  50. data/test/adapter_test.rb +2 -2
  51. data/test/array_serializer_test.rb +11 -7
  52. data/test/capture_warnings.rb +8 -7
  53. data/test/fixtures/active_record.rb +0 -1
  54. data/test/fixtures/poro.rb +7 -12
  55. data/test/generators/scaffold_controller_generator_test.rb +1 -2
  56. data/test/generators/serializer_generator_test.rb +10 -10
  57. data/test/lint_test.rb +0 -7
  58. data/test/serializers/adapter_for_test.rb +0 -1
  59. data/test/serializers/associations_test.rb +4 -4
  60. data/test/serializers/attribute_test.rb +7 -7
  61. data/test/serializers/attributes_test.rb +8 -14
  62. data/test/serializers/cache_test.rb +8 -7
  63. data/test/serializers/fieldset_test.rb +3 -4
  64. data/test/serializers/meta_test.rb +23 -23
  65. data/test/serializers/root_test.rb +1 -3
  66. data/test/serializers/serializer_for_test.rb +1 -1
  67. data/test/support/serialization_testing.rb +13 -0
  68. data/test/support/simplecov.rb +6 -0
  69. data/test/support/stream_capture.rb +2 -2
  70. data/test/test_helper.rb +14 -2
  71. metadata +13 -6
  72. data/test/serializers/urls_test.rb +0 -26
@@ -13,7 +13,7 @@ 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
 
@@ -21,16 +21,16 @@ module ActiveModel
21
21
  end
22
22
 
23
23
  def test_with_serializer_option
24
- @blog.special_attribute = "Special"
24
+ @blog.special_attribute = 'Special'
25
25
  @blog.articles = [@first_post, @second_post]
26
26
  serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
27
27
  adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
28
28
 
29
- expected = {blogs:[{
29
+ expected = { blogs: [{
30
30
  id: 1,
31
- special_attribute: "Special",
32
- articles: [{id: 1,title: "Hello!!", body: "Hello, world!!"}, {id: 2, title: "New Post", body: "Body"}]
33
- }]}
31
+ special_attribute: 'Special',
32
+ articles: [{ id: 1, title: 'Hello!!', body: 'Hello, world!!' }, { id: 2, title: 'New Post', body: 'Body' }]
33
+ }] }
34
34
  assert_equal expected, adapter.serializable_hash
35
35
  end
36
36
 
@@ -39,32 +39,32 @@ module ActiveModel
39
39
  adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
40
40
 
41
41
  expected = { posts: [{
42
- title: "Hello!!",
43
- body: "Hello, world!!",
42
+ title: 'Hello!!',
43
+ body: 'Hello, world!!',
44
44
  id: 1,
45
45
  comments: [],
46
46
  author: {
47
47
  id: 1,
48
- name: "Steve K."
48
+ name: 'Steve K.'
49
49
  },
50
50
  blog: {
51
51
  id: 999,
52
- name: "Custom blog"
52
+ name: 'Custom blog'
53
53
  }
54
54
  }, {
55
- title: "New Post",
56
- body: "Body",
55
+ title: 'New Post',
56
+ body: 'Body',
57
57
  id: 2,
58
58
  comments: [],
59
59
  author: {
60
60
  id: 1,
61
- name: "Steve K."
61
+ name: 'Steve K.'
62
62
  },
63
63
  blog: {
64
64
  id: 999,
65
- name: "Custom blog"
65
+ name: 'Custom blog'
66
66
  }
67
- }]}
67
+ }] }
68
68
  assert_equal expected, adapter.serializable_hash
69
69
  end
70
70
 
@@ -15,9 +15,9 @@ module ActiveModel
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
- @tag = Tag.new(id: 1, name: "#hash_tag")
20
+ @tag = Tag.new(id: 1, name: '#hash_tag')
21
21
  @post.tags = [@tag]
22
22
  end
23
23
 
@@ -25,8 +25,8 @@ module ActiveModel
25
25
  serializer = PostSerializer.new(@post)
26
26
  adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
27
27
  assert_equal([
28
- {id: 1, body: 'ZOMG A COMMENT'},
29
- {id: 2, body: 'ZOMG ANOTHER COMMENT'}
28
+ { id: 1, body: 'ZOMG A COMMENT' },
29
+ { id: 2, body: 'ZOMG ANOTHER COMMENT' }
30
30
  ], adapter.serializable_hash[:post][:comments])
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ module ActiveModel
36
36
  assert_equal({
37
37
  id: 42,
38
38
  tags: [
39
- {"attributes"=>{"id"=>1, "name"=>"#hash_tag"}}
39
+ { 'attributes' => { 'id' => 1, 'name' => '#hash_tag' } }
40
40
  ]
41
41
  }.to_json, adapter.serializable_hash[:post].to_json)
42
42
  end
@@ -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,7 +32,7 @@ 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
@@ -40,33 +40,33 @@ module ActiveModel
40
40
  def test_includes_linked_post
41
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: %w(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
@@ -27,8 +27,8 @@ module ActiveModel
27
27
  def test_includes_comment_ids
28
28
  expected = {
29
29
  data: [
30
- { type: "posts", id: "1"},
31
- { type: "posts", id: "2"}
30
+ { type: 'posts', id: '1' },
31
+ { type: 'posts', id: '2' }
32
32
  ]
33
33
  }
34
34
 
@@ -24,7 +24,7 @@ module ActiveModel
24
24
  @serializer = PostPreviewSerializer.new(@post)
25
25
  @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(
26
26
  @serializer,
27
- include: ['comments', 'author']
27
+ include: %w(comments author)
28
28
  )
29
29
  end
30
30
 
@@ -58,9 +58,9 @@ module ActiveModel
58
58
  },
59
59
  {
60
60
  id: @author.id.to_s,
61
- type: "authors",
61
+ type: 'authors',
62
62
  relationships: {
63
- posts: { data: [ {type: "posts", id: @post.id.to_s } ] }
63
+ posts: { data: [{ type: 'posts', id: @post.id.to_s }] }
64
64
  }
65
65
  }
66
66
  ]
@@ -70,7 +70,7 @@ module ActiveModel
70
70
 
71
71
  def test_includes_author_id
72
72
  expected = {
73
- data: { type: "authors", id: @author.id.to_s }
73
+ data: { type: 'authors', id: @author.id.to_s }
74
74
  }
75
75
 
76
76
  assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:author])
@@ -22,12 +22,12 @@ module ActiveModel
22
22
  @second_comment.post = @post
23
23
  @post.author = @author
24
24
  @post_without_comments.author = nil
25
- @blog = Blog.new(id: 1, name: "My Blog!!")
25
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
26
26
  @blog.writer = @author
27
27
  @blog.articles = [@post]
28
28
  @post.blog = @blog
29
29
  @post_without_comments.blog = nil
30
- @tag = Tag.new(id: 1, name: "#hash_tag")
30
+ @tag = Tag.new(id: 1, name: '#hash_tag')
31
31
  @post.tags = [@tag]
32
32
  @serializer = PostSerializer.new(@post)
33
33
  @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
@@ -36,7 +36,7 @@ module ActiveModel
36
36
  end
37
37
 
38
38
  def test_includes_comment_ids
39
- expected = { data: [ { type: "comments", id: "1" }, { type: "comments", id: "2" } ] }
39
+ expected = { data: [{ type: 'comments', id: '1' }, { type: 'comments', id: '2' }] }
40
40
 
41
41
  assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:comments])
42
42
  end
@@ -44,23 +44,23 @@ module ActiveModel
44
44
  def test_includes_linked_comments
45
45
  @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments')
46
46
  expected = [{
47
- id: "1",
48
- type: "comments",
47
+ id: '1',
48
+ type: 'comments',
49
49
  attributes: {
50
50
  body: 'ZOMG A COMMENT'
51
51
  },
52
52
  relationships: {
53
- post: { data: { type: "posts", id: "1" } },
53
+ post: { data: { type: 'posts', id: '1' } },
54
54
  author: { data: nil }
55
55
  }
56
56
  }, {
57
- id: "2",
58
- type: "comments",
57
+ id: '2',
58
+ type: 'comments',
59
59
  attributes: {
60
60
  body: 'ZOMG ANOTHER COMMENT'
61
61
  },
62
62
  relationships: {
63
- post: { data: { type: "posts", id: "1" } },
63
+ post: { data: { type: 'posts', id: '1' } },
64
64
  author: { data: nil }
65
65
  }
66
66
  }]
@@ -68,19 +68,19 @@ module ActiveModel
68
68
  end
69
69
 
70
70
  def test_limit_fields_of_linked_comments
71
- @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments', fields: {comment: [:id]})
71
+ @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments', fields: { comment: [:id] })
72
72
  expected = [{
73
- id: "1",
74
- type: "comments",
73
+ id: '1',
74
+ type: 'comments',
75
75
  relationships: {
76
- post: { data: { type: "posts", id: "1" } },
76
+ post: { data: { type: 'posts', id: '1' } },
77
77
  author: { data: nil }
78
78
  }
79
79
  }, {
80
- id: "2",
81
- type: "comments",
80
+ id: '2',
81
+ type: 'comments',
82
82
  relationships: {
83
- post: { data: { type: "posts", id: "1" } },
83
+ post: { data: { type: 'posts', id: '1' } },
84
84
  author: { data: nil }
85
85
  }
86
86
  }]
@@ -101,8 +101,8 @@ module ActiveModel
101
101
 
102
102
  expected = {
103
103
  data: [{
104
- type: "posts",
105
- id: "1"
104
+ type: 'posts',
105
+ id: '1'
106
106
  }]
107
107
  }
108
108
  assert_equal expected, actual
@@ -114,10 +114,10 @@ module ActiveModel
114
114
 
115
115
  assert_equal({
116
116
  data: {
117
- id: "1",
118
- type: "posts",
117
+ id: '1',
118
+ type: 'posts',
119
119
  relationships: {
120
- tags: { data: [@tag.as_json]}
120
+ tags: { data: [@tag.as_json] }
121
121
  }
122
122
  }
123
123
  }, adapter.serializable_hash)
@@ -129,11 +129,11 @@ module ActiveModel
129
129
 
130
130
  assert_equal({
131
131
  data: {
132
- id: "1",
133
- type: "virtual_values",
132
+ id: '1',
133
+ type: 'virtual_values',
134
134
  relationships: {
135
- maker: {data: {id: 1}},
136
- reviews: {data: [{id: 1}, {id: 2}]}
135
+ maker: { data: { id: 1 } },
136
+ reviews: { data: [{ id: 1 }, { id: 2 }] }
137
137
  }
138
138
  }
139
139
  }, adapter.serializable_hash)
@@ -19,7 +19,7 @@ module ActiveModel
19
19
  @comment.author = nil
20
20
  @post.author = @author
21
21
  @anonymous_post.author = nil
22
- @blog = Blog.new(id: 1, name: "My Blog!!")
22
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
23
23
  @blog.writer = @author
24
24
  @blog.articles = [@post, @anonymous_post]
25
25
  @author.posts = []
@@ -32,7 +32,7 @@ module ActiveModel
32
32
  end
33
33
 
34
34
  def test_includes_bio_id
35
- expected = { data: { type: "bios", id: "43" } }
35
+ expected = { data: { type: 'bios', id: '43' } }
36
36
 
37
37
  assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:bio])
38
38
  end
@@ -42,14 +42,14 @@ module ActiveModel
42
42
 
43
43
  expected = [
44
44
  {
45
- id: "43",
46
- type: "bios",
45
+ id: '43',
46
+ type: 'bios',
47
47
  attributes: {
48
- content:"AMS Contributor",
48
+ content: 'AMS Contributor',
49
49
  rating: nil
50
50
  },
51
51
  relationships: {
52
- author: { data: { type: "authors", id: "1" } }
52
+ author: { data: { type: 'authors', id: '1' } }
53
53
  }
54
54
  }
55
55
  ]
@@ -63,11 +63,11 @@ module ActiveModel
63
63
 
64
64
  expected = {
65
65
  data: {
66
- id: "1",
67
- type: "virtual_values",
66
+ id: '1',
67
+ type: 'virtual_values',
68
68
  relationships: {
69
- maker: {data: {id: 1}},
70
- reviews: {data: [{id: 1}, {id: 2}]}
69
+ maker: { data: { id: 1 } },
70
+ reviews: { data: [{ id: 1 }, { id: 2 }] }
71
71
  }
72
72
  }
73
73
  }
@@ -14,9 +14,8 @@ module ActiveModel
14
14
  @first_comment.post = @post
15
15
  @second_comment.post = @post
16
16
  @post.author = @author
17
- @blog = Blog.new(id: 1, name: "My Blog!!")
17
+ @blog = Blog.new(id: 1, name: 'My Blog!!')
18
18
  @post.blog = @blog
19
-
20
19
  end
21
20
 
22
21
  def test_custom_keys
@@ -25,11 +24,11 @@ module ActiveModel
25
24
 
26
25
  assert_equal({
27
26
  reviews: { data: [
28
- {type: "comments", id: "1"},
29
- {type: "comments", id: "2"}
30
- ]},
31
- writer: { data: {type: "authors", id: "1"} },
32
- site: { data: {type: "blogs", id: "1" } }
27
+ { type: 'comments', id: '1' },
28
+ { type: 'comments', id: '2' }
29
+ ] },
30
+ writer: { data: { type: 'authors', id: '1' } },
31
+ site: { data: { type: 'blogs', id: '1' } }
33
32
  }, adapter.serializable_hash[:data][:relationships])
34
33
  end
35
34
  end