active_model_serializers 0.10.0 → 0.10.2

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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -4
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +39 -2
  5. data/Gemfile +1 -1
  6. data/README.md +21 -24
  7. data/Rakefile +3 -3
  8. data/active_model_serializers.gemspec +19 -23
  9. data/docs/general/adapters.md +4 -2
  10. data/docs/general/configuration_options.md +6 -1
  11. data/docs/general/deserialization.md +1 -1
  12. data/docs/general/fields.md +31 -0
  13. data/docs/general/rendering.md +7 -2
  14. data/docs/general/serializers.md +62 -3
  15. data/docs/howto/add_pagination_links.md +2 -3
  16. data/docs/integrations/ember-and-json-api.md +25 -10
  17. data/docs/jsonapi/schema.md +1 -1
  18. data/lib/action_controller/serialization.rb +4 -3
  19. data/lib/active_model/serializer/adapter/base.rb +2 -0
  20. data/lib/active_model/serializer/array_serializer.rb +8 -5
  21. data/lib/active_model/serializer/associations.rb +6 -7
  22. data/lib/active_model/serializer/belongs_to_reflection.rb +0 -3
  23. data/lib/active_model/serializer/caching.rb +67 -112
  24. data/lib/active_model/serializer/collection_serializer.rb +30 -10
  25. data/lib/active_model/serializer/configuration.rb +1 -0
  26. data/lib/active_model/serializer/error_serializer.rb +11 -7
  27. data/lib/active_model/serializer/errors_serializer.rb +25 -20
  28. data/lib/active_model/serializer/has_many_reflection.rb +0 -3
  29. data/lib/active_model/serializer/has_one_reflection.rb +0 -3
  30. data/lib/active_model/serializer/lint.rb +134 -130
  31. data/lib/active_model/serializer/reflection.rb +3 -3
  32. data/lib/active_model/serializer/version.rb +1 -1
  33. data/lib/active_model/serializer.rb +57 -15
  34. data/lib/active_model_serializers/adapter/attributes.rb +2 -67
  35. data/lib/active_model_serializers/adapter/base.rb +38 -38
  36. data/lib/active_model_serializers/adapter/json_api/link.rb +1 -1
  37. data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +8 -1
  38. data/lib/active_model_serializers/adapter/json_api.rb +36 -28
  39. data/lib/active_model_serializers/adapter.rb +6 -0
  40. data/lib/active_model_serializers/deprecate.rb +1 -2
  41. data/lib/active_model_serializers/deserialization.rb +2 -0
  42. data/lib/active_model_serializers/model.rb +3 -1
  43. data/lib/active_model_serializers/railtie.rb +3 -1
  44. data/lib/active_model_serializers/register_jsonapi_renderer.rb +44 -31
  45. data/lib/active_model_serializers/serialization_context.rb +10 -3
  46. data/lib/active_model_serializers.rb +6 -0
  47. data/lib/generators/rails/serializer_generator.rb +3 -3
  48. data/lib/grape/active_model_serializers.rb +7 -5
  49. data/lib/grape/formatters/active_model_serializers.rb +19 -2
  50. data/lib/grape/helpers/active_model_serializers.rb +1 -0
  51. data/test/action_controller/adapter_selector_test.rb +4 -4
  52. data/test/action_controller/explicit_serializer_test.rb +5 -4
  53. data/test/action_controller/json/include_test.rb +106 -27
  54. data/test/action_controller/json_api/errors_test.rb +6 -7
  55. data/test/action_controller/json_api/linked_test.rb +29 -24
  56. data/test/action_controller/json_api/pagination_test.rb +19 -19
  57. data/test/action_controller/serialization_test.rb +10 -7
  58. data/test/active_model_serializers/json_pointer_test.rb +15 -13
  59. data/test/active_model_serializers/key_transform_test.rb +254 -252
  60. data/test/active_model_serializers/model_test.rb +6 -4
  61. data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +143 -0
  62. data/test/active_model_serializers/serialization_context_test_isolated.rb +23 -10
  63. data/test/adapter/json/collection_test.rb +14 -0
  64. data/test/adapter/json/transform_test.rb +14 -14
  65. data/test/adapter/json_api/collection_test.rb +4 -3
  66. data/test/adapter/json_api/errors_test.rb +17 -19
  67. data/test/adapter/json_api/has_many_test.rb +18 -18
  68. data/test/adapter/json_api/json_api_test.rb +5 -7
  69. data/test/adapter/json_api/linked_test.rb +9 -6
  70. data/test/adapter/json_api/links_test.rb +3 -1
  71. data/test/adapter/json_api/pagination_links_test.rb +19 -7
  72. data/test/adapter/json_api/relationships_test.rb +9 -4
  73. data/test/adapter/json_api/resource_identifier_test.rb +7 -2
  74. data/test/adapter/json_api/resource_meta_test.rb +3 -3
  75. data/test/adapter/json_api/transform_test.rb +251 -250
  76. data/test/adapter/json_api/type_test.rb +1 -1
  77. data/test/adapter/json_test.rb +8 -7
  78. data/test/adapter/null_test.rb +1 -2
  79. data/test/adapter/polymorphic_test.rb +5 -5
  80. data/test/adapter_test.rb +1 -1
  81. data/test/benchmark/app.rb +1 -1
  82. data/test/benchmark/bm_caching.rb +15 -15
  83. data/test/benchmark/bm_transform.rb +16 -5
  84. data/test/benchmark/controllers.rb +16 -17
  85. data/test/benchmark/fixtures.rb +72 -72
  86. data/test/cache_test.rb +101 -45
  87. data/test/collection_serializer_test.rb +2 -2
  88. data/test/fixtures/poro.rb +8 -7
  89. data/test/grape_test.rb +152 -56
  90. data/test/lint_test.rb +1 -1
  91. data/test/logger_test.rb +13 -11
  92. data/test/serializable_resource_test.rb +18 -22
  93. data/test/serializers/associations_test.rb +10 -10
  94. data/test/serializers/attribute_test.rb +1 -1
  95. data/test/serializers/attributes_test.rb +1 -1
  96. data/test/serializers/fieldset_test.rb +1 -1
  97. data/test/serializers/meta_test.rb +12 -6
  98. data/test/serializers/root_test.rb +1 -1
  99. data/test/serializers/serializer_for_test.rb +3 -1
  100. data/test/support/isolated_unit.rb +5 -2
  101. data/test/support/rails5_shims.rb +8 -2
  102. data/test/support/rails_app.rb +0 -9
  103. data/test/support/serialization_testing.rb +7 -5
  104. metadata +54 -24
  105. data/.rubocop_todo.yml +0 -167
  106. data/lib/active_model/serializer/include_tree.rb +0 -111
  107. data/test/include_tree/from_include_args_test.rb +0 -26
  108. data/test/include_tree/from_string_test.rb +0 -94
  109. data/test/include_tree/include_args_to_hash_test.rb +0 -64
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module ActiveModelSerializers
4
4
  class SerializableResourceTest < ActiveSupport::TestCase
5
5
  def setup
6
- @resource = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
6
+ @resource = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
7
7
  @serializer = ProfileSerializer.new(@resource)
8
8
  @adapter = ActiveModelSerializers::Adapter.create(@serializer)
9
9
  @serializable_resource = SerializableResource.new(@resource)
@@ -32,11 +32,11 @@ module ActiveModelSerializers
32
32
  end
33
33
 
34
34
  def test_use_adapter_with_adapter_option
35
- assert SerializableResource.new(@resource, { adapter: 'json' }).use_adapter?
35
+ assert SerializableResource.new(@resource, adapter: 'json').use_adapter?
36
36
  end
37
37
 
38
38
  def test_use_adapter_with_adapter_option_as_false
39
- refute SerializableResource.new(@resource, { adapter: false }).use_adapter?
39
+ refute SerializableResource.new(@resource, adapter: false).use_adapter?
40
40
  end
41
41
 
42
42
  class SerializableResourceErrorsTest < Minitest::Test
@@ -45,15 +45,13 @@ module ActiveModelSerializers
45
45
  resource = ModelWithErrors.new
46
46
  resource.errors.add(:name, 'must be awesome')
47
47
  serializable_resource = ActiveModelSerializers::SerializableResource.new(
48
- resource, {
49
- serializer: ActiveModel::Serializer::ErrorSerializer,
50
- adapter: :json_api
51
- })
52
- expected_response_document =
53
- { :errors =>
54
- [
55
- { :source => { :pointer => '/data/attributes/name' }, :detail => 'must be awesome' }
56
- ]
48
+ resource, serializer: ActiveModel::Serializer::ErrorSerializer,
49
+ adapter: :json_api
50
+ )
51
+ expected_response_document = {
52
+ errors: [
53
+ { source: { pointer: '/data/attributes/name' }, detail: 'must be awesome' }
54
+ ]
57
55
  }
58
56
  assert_equal serializable_resource.as_json(options), expected_response_document
59
57
  end
@@ -65,16 +63,14 @@ module ActiveModelSerializers
65
63
  resource.errors.add(:title, 'must be amazing')
66
64
  resources << ModelWithErrors.new
67
65
  serializable_resource = SerializableResource.new(
68
- resources, {
69
- serializer: ActiveModel::Serializer::ErrorsSerializer,
70
- each_serializer: ActiveModel::Serializer::ErrorSerializer,
71
- adapter: :json_api
72
- })
73
- expected_response_document =
74
- { :errors =>
75
- [
76
- { :source => { :pointer => '/data/attributes/title' }, :detail => 'must be amazing' }
77
- ]
66
+ resources, serializer: ActiveModel::Serializer::ErrorsSerializer,
67
+ each_serializer: ActiveModel::Serializer::ErrorSerializer,
68
+ adapter: :json_api
69
+ )
70
+ expected_response_document = {
71
+ errors: [
72
+ { source: { pointer: '/data/attributes/title' }, detail: 'must be amazing' }
73
+ ]
78
74
  }
79
75
  assert_equal serializable_resource.as_json(options), expected_response_document
80
76
  end
@@ -7,10 +7,10 @@ module ActiveModel
7
7
  @author = Author.new(name: 'Steve K.')
8
8
  @author.bio = nil
9
9
  @author.roles = []
10
- @blog = Blog.new({ name: 'AMS Blog' })
11
- @post = Post.new({ title: 'New Post', body: 'Body' })
12
- @tag = Tag.new({ name: '#hashtagged' })
13
- @comment = Comment.new({ id: 1, body: 'ZOMG A COMMENT' })
10
+ @blog = Blog.new(name: 'AMS Blog')
11
+ @post = Post.new(title: 'New Post', body: 'Body')
12
+ @tag = Tag.new(name: '#hashtagged')
13
+ @comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
14
14
  @post.comments = [@comment]
15
15
  @post.tags = [@tag]
16
16
  @post.blog = @blog
@@ -19,7 +19,7 @@ module ActiveModel
19
19
  @post.author = @author
20
20
  @author.posts = [@post]
21
21
 
22
- @post_serializer = PostSerializer.new(@post, { custom_options: true })
22
+ @post_serializer = PostSerializer.new(@post, custom_options: true)
23
23
  @author_serializer = AuthorSerializer.new(@author)
24
24
  @comment_serializer = CommentSerializer.new(@comment)
25
25
  end
@@ -143,12 +143,12 @@ module ActiveModel
143
143
  )
144
144
  actual = serializable(post, adapter: :attributes, serializer: InlineAssociationTestPostSerializer).as_json
145
145
  expected = {
146
- :comments => [
147
- { :id => 1, :contents => 'first comment' },
148
- { :id => 2, :contents => 'last comment' }
146
+ comments: [
147
+ { id: 1, contents: 'first comment' },
148
+ { id: 2, contents: 'last comment' }
149
149
  ],
150
- :last_comments => [
151
- { :id => 2, :contents => 'last comment' }
150
+ last_comments: [
151
+ { id: 2, contents: 'last comment' }
152
152
  ]
153
153
  }
154
154
 
@@ -22,7 +22,7 @@ module ActiveModel
22
22
  inherited_klass = Class.new(AlternateBlogSerializer)
23
23
  blog_serializer = inherited_klass.new(@blog)
24
24
  adapter = ActiveModelSerializers::Adapter::Attributes.new(blog_serializer)
25
- assert_equal({ :id => 1, :title => 'AMS Hints' }, adapter.serializable_hash)
25
+ assert_equal({ id: 1, title: 'AMS Hints' }, adapter.serializable_hash)
26
26
  end
27
27
 
28
28
  def test_multiple_calls_with_the_same_attribute
@@ -4,7 +4,7 @@ module ActiveModel
4
4
  class Serializer
5
5
  class AttributesTest < ActiveSupport::TestCase
6
6
  def setup
7
- @profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
7
+ @profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
8
8
  @profile_serializer = ProfileSerializer.new(@profile)
9
9
  @comment = Comment.new(id: 1, body: 'ZOMG!!', date: '2015')
10
10
  @serializer_klass = Class.new(CommentSerializer)
@@ -5,7 +5,7 @@ module ActiveModel
5
5
  class FieldsetTest < ActiveSupport::TestCase
6
6
  def test_fieldset_with_hash
7
7
  fieldset = ActiveModel::Serializer::Fieldset.new('post' => %w(id title), 'comment' => ['body'])
8
- expected = { :post => [:id, :title], :comment => [:body] }
8
+ expected = { post: [:id, :title], comment: [:body] }
9
9
 
10
10
  assert_equal(expected, fieldset.fields)
11
11
  end
@@ -15,7 +15,8 @@ module ActiveModel
15
15
  @blog,
16
16
  adapter: :json,
17
17
  serializer: AlternateBlogSerializer,
18
- meta: { total: 10 }).as_json
18
+ meta: { total: 10 }
19
+ ).as_json
19
20
  expected = {
20
21
  blog: {
21
22
  id: 1,
@@ -65,7 +66,8 @@ module ActiveModel
65
66
  @blog,
66
67
  adapter: :attributes,
67
68
  serializer: AlternateBlogSerializer,
68
- meta: { total: 10 }).as_json
69
+ meta: { total: 10 }
70
+ ).as_json
69
71
  expected = {
70
72
  id: 1,
71
73
  title: 'AMS Hints'
@@ -79,7 +81,8 @@ module ActiveModel
79
81
  adapter: :json,
80
82
  serializer: AlternateBlogSerializer,
81
83
  meta: { total: 10 },
82
- meta_key: 'haha_meta').as_json
84
+ meta_key: 'haha_meta'
85
+ ).as_json
83
86
  expected = {
84
87
  blog: {
85
88
  id: 1,
@@ -98,7 +101,8 @@ module ActiveModel
98
101
  adapter: :json_api,
99
102
  serializer: AlternateBlogSerializer,
100
103
  meta: { total: 10 },
101
- meta_key: 'haha_meta').as_json
104
+ meta_key: 'haha_meta'
105
+ ).as_json
102
106
  expected = {
103
107
  data: {
104
108
  id: '1',
@@ -148,7 +152,8 @@ module ActiveModel
148
152
  actual = ActiveModelSerializers::SerializableResource.new(
149
153
  [@blog],
150
154
  adapter: :attributes,
151
- meta: { total: 10 }).as_json
155
+ meta: { total: 10 }
156
+ ).as_json
152
157
  expected = [{
153
158
  id: 1,
154
159
  name: 'AMS Hints',
@@ -170,7 +175,8 @@ module ActiveModel
170
175
  [@blog],
171
176
  adapter: :json,
172
177
  meta: { total: 10 },
173
- meta_key: 'haha_meta').as_json
178
+ meta_key: 'haha_meta'
179
+ ).as_json
174
180
  expected = {
175
181
  blogs: [{
176
182
  id: 1,
@@ -8,7 +8,7 @@ module ActiveModel
8
8
  end
9
9
 
10
10
  def test_overwrite_root
11
- serializer = VirtualValueSerializer.new(@virtual_value, { root: 'smth' })
11
+ serializer = VirtualValueSerializer.new(@virtual_value, root: 'smth')
12
12
  assert_equal('smth', serializer.json_key)
13
13
  end
14
14
 
@@ -41,7 +41,9 @@ module ActiveModel
41
41
  end
42
42
 
43
43
  class CustomProfile
44
- def serializer_class; ProfileSerializer; end
44
+ def serializer_class
45
+ ProfileSerializer
46
+ end
45
47
  end
46
48
 
47
49
  Tweet = Class.new(::Model)
@@ -41,6 +41,7 @@ require 'active_support/core_ext/string/access'
41
41
 
42
42
  # These files do not require any others and are needed
43
43
  # to run the tests
44
+ require 'active_support/testing/autorun'
44
45
  require 'active_support/testing/isolation'
45
46
 
46
47
  module TestHelpers
@@ -74,6 +75,8 @@ module TestHelpers
74
75
  end
75
76
  end
76
77
 
77
- class ActiveSupport::TestCase
78
- include TestHelpers::Generation
78
+ module ActiveSupport
79
+ class TestCase
80
+ include TestHelpers::Generation
81
+ end
79
82
  end
@@ -1,7 +1,7 @@
1
1
  module Rails5Shims
2
2
  module ControllerTests
3
3
  # https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
4
- REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr].freeze
4
+ REQUEST_KWARGS = [:params, :headers, :session, :flash, :method, :body, :xhr].freeze
5
5
 
6
6
  def get(path, *args)
7
7
  fold_kwargs!(args)
@@ -30,7 +30,12 @@ module Rails5Shims
30
30
  return unless hash.respond_to?(:key)
31
31
  Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
32
32
  next unless hash.key?(kwarg)
33
- hash.merge! hash.delete(kwarg)
33
+ value = hash.delete(kwarg)
34
+ if value.is_a? String
35
+ args.insert(0, value)
36
+ else
37
+ hash.merge! value
38
+ end
34
39
  end
35
40
  end
36
41
 
@@ -44,4 +49,5 @@ module Rails5Shims
44
49
  end
45
50
  if Rails::VERSION::MAJOR < 5
46
51
  ActionController::TestCase.send :include, Rails5Shims::ControllerTests
52
+ ActionDispatch::IntegrationTest.send :include, Rails5Shims::ControllerTests
47
53
  end
@@ -22,15 +22,6 @@ ActionController::TestCase.class_eval do
22
22
  def setup
23
23
  @routes = Routes
24
24
  end
25
-
26
- # For Rails5
27
- # https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17
28
- def assigns(key = nil)
29
- warn "DEPRECATION: Calling 'assigns(#{key})' from #{caller[0]}"
30
- assigns = {}.with_indifferent_access
31
- @controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
32
- key.nil? ? assigns : assigns[key]
33
- end
34
25
  end
35
26
 
36
27
  # ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
@@ -44,10 +44,12 @@ module SerializationTesting
44
44
  end
45
45
  end
46
46
 
47
- class Minitest::Test
48
- def before_setup
49
- ActionController::Base.cache_store.clear
50
- end
47
+ module Minitest
48
+ class Test
49
+ def before_setup
50
+ ActionController::Base.cache_store.clear
51
+ end
51
52
 
52
- include SerializationTesting
53
+ include SerializationTesting
54
+ end
53
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Klabnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-17 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,56 +16,94 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '4.0'
29
+ version: '4.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: actionpack
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '4.0'
39
+ version: '4.1'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: '4.0'
49
+ version: '4.1'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: railties
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - ">="
46
58
  - !ruby/object:Gem::Version
47
- version: '4.0'
59
+ version: '4.1'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '6'
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
67
  - - ">="
53
68
  - !ruby/object:Gem::Version
54
- version: '4.0'
69
+ version: '4.1'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '6'
73
+ - !ruby/object:Gem::Dependency
74
+ name: jsonapi
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 0.1.1.beta2
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: 0.1.1.beta2
55
87
  - !ruby/object:Gem::Dependency
56
88
  name: activerecord
57
89
  requirement: !ruby/object:Gem::Requirement
58
90
  requirements:
59
91
  - - ">="
60
92
  - !ruby/object:Gem::Version
61
- version: '4.0'
93
+ version: '4.1'
94
+ - - "<"
95
+ - !ruby/object:Gem::Version
96
+ version: '6'
62
97
  type: :development
63
98
  prerelease: false
64
99
  version_requirements: !ruby/object:Gem::Requirement
65
100
  requirements:
66
101
  - - ">="
67
102
  - !ruby/object:Gem::Version
68
- version: '4.0'
103
+ version: '4.1'
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '6'
69
107
  - !ruby/object:Gem::Dependency
70
108
  name: kaminari
71
109
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +246,6 @@ files:
208
246
  - ".github/PULL_REQUEST_TEMPLATE.md"
209
247
  - ".gitignore"
210
248
  - ".rubocop.yml"
211
- - ".rubocop_todo.yml"
212
249
  - ".simplecov"
213
250
  - ".travis.yml"
214
251
  - CHANGELOG.md
@@ -229,6 +266,7 @@ files:
229
266
  - docs/general/caching.md
230
267
  - docs/general/configuration_options.md
231
268
  - docs/general/deserialization.md
269
+ - docs/general/fields.md
232
270
  - docs/general/getting_started.md
233
271
  - docs/general/instrumentation.md
234
272
  - docs/general/key_transforms.md
@@ -274,7 +312,6 @@ files:
274
312
  - lib/active_model/serializer/fieldset.rb
275
313
  - lib/active_model/serializer/has_many_reflection.rb
276
314
  - lib/active_model/serializer/has_one_reflection.rb
277
- - lib/active_model/serializer/include_tree.rb
278
315
  - lib/active_model/serializer/links.rb
279
316
  - lib/active_model/serializer/lint.rb
280
317
  - lib/active_model/serializer/meta.rb
@@ -335,6 +372,7 @@ files:
335
372
  - test/active_model_serializers/logging_test.rb
336
373
  - test/active_model_serializers/model_test.rb
337
374
  - test/active_model_serializers/railtie_test_isolated.rb
375
+ - test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb
338
376
  - test/active_model_serializers/serialization_context_test_isolated.rb
339
377
  - test/active_model_serializers/test/schema_test.rb
340
378
  - test/active_model_serializers/test/serializer_test.rb
@@ -383,9 +421,6 @@ files:
383
421
  - test/generators/scaffold_controller_generator_test.rb
384
422
  - test/generators/serializer_generator_test.rb
385
423
  - test/grape_test.rb
386
- - test/include_tree/from_include_args_test.rb
387
- - test/include_tree/from_string_test.rb
388
- - test/include_tree/include_args_to_hash_test.rb
389
424
  - test/lint_test.rb
390
425
  - test/logger_test.rb
391
426
  - test/poro_test.rb
@@ -419,10 +454,7 @@ homepage: https://github.com/rails-api/active_model_serializers
419
454
  licenses:
420
455
  - MIT
421
456
  metadata: {}
422
- post_install_message: |
423
- NOTE: The default key case for the JsonApi adapter has changed to dashed.
424
- See https://github.com/rails-api/active_model_serializers/blob/master/docs/general/key_transforms.md
425
- for more information on configuring this behavior.
457
+ post_install_message:
426
458
  rdoc_options: []
427
459
  require_paths:
428
460
  - lib
@@ -430,7 +462,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
430
462
  requirements:
431
463
  - - ">="
432
464
  - !ruby/object:Gem::Version
433
- version: 2.0.0
465
+ version: '2.1'
434
466
  required_rubygems_version: !ruby/object:Gem::Requirement
435
467
  requirements:
436
468
  - - ">="
@@ -438,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
438
470
  version: '0'
439
471
  requirements: []
440
472
  rubyforge_project:
441
- rubygems_version: 2.4.5
473
+ rubygems_version: 2.4.8
442
474
  signing_key:
443
475
  specification_version: 4
444
476
  summary: Conventions-based JSON generation for Rails.
@@ -459,6 +491,7 @@ test_files:
459
491
  - test/active_model_serializers/logging_test.rb
460
492
  - test/active_model_serializers/model_test.rb
461
493
  - test/active_model_serializers/railtie_test_isolated.rb
494
+ - test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb
462
495
  - test/active_model_serializers/serialization_context_test_isolated.rb
463
496
  - test/active_model_serializers/test/schema_test.rb
464
497
  - test/active_model_serializers/test/serializer_test.rb
@@ -507,9 +540,6 @@ test_files:
507
540
  - test/generators/scaffold_controller_generator_test.rb
508
541
  - test/generators/serializer_generator_test.rb
509
542
  - test/grape_test.rb
510
- - test/include_tree/from_include_args_test.rb
511
- - test/include_tree/from_string_test.rb
512
- - test/include_tree/include_args_to_hash_test.rb
513
543
  - test/lint_test.rb
514
544
  - test/logger_test.rb
515
545
  - test/poro_test.rb
data/.rubocop_todo.yml DELETED
@@ -1,167 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2016-03-08 22:29:52 +0100 using RuboCop version 0.37.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- Lint/HandleExceptions:
11
- Exclude:
12
- - 'Rakefile'
13
-
14
- # Offense count: 2
15
- # Cop supports --auto-correct.
16
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
17
- Lint/UnusedMethodArgument:
18
- Exclude:
19
- - 'test/lint_test.rb'
20
-
21
- # Offense count: 4
22
- # Configuration parameters: EnforcedStyle, SupportedStyles.
23
- # SupportedStyles: strict, flexible
24
- Rails/TimeZone:
25
- Exclude:
26
- - 'test/action_controller/serialization_test.rb'
27
- - 'test/serializers/cache_test.rb'
28
-
29
- # Offense count: 16
30
- # Cop supports --auto-correct.
31
- # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
32
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
33
- Style/AlignHash:
34
- Exclude:
35
- - 'test/action_controller/json_api/pagination_test.rb'
36
-
37
- # Offense count: 27
38
- # Cop supports --auto-correct.
39
- # Configuration parameters: EnforcedStyle, SupportedStyles.
40
- # SupportedStyles: braces, no_braces, context_dependent
41
- Style/BracesAroundHashParameters:
42
- Exclude:
43
- - 'test/action_controller/adapter_selector_test.rb'
44
- - 'test/action_controller/json_api/pagination_test.rb'
45
- - 'test/adapter/json_api/linked_test.rb'
46
- - 'test/adapter/json_api/pagination_links_test.rb'
47
- - 'test/adapter/null_test.rb'
48
- - 'test/adapter_test.rb'
49
- - 'test/collection_serializer_test.rb'
50
- - 'test/serializable_resource_test.rb'
51
- - 'test/serializers/associations_test.rb'
52
- - 'test/serializers/attributes_test.rb'
53
- - 'test/serializers/root_test.rb'
54
-
55
- # Offense count: 271
56
- # Configuration parameters: EnforcedStyle, SupportedStyles.
57
- # SupportedStyles: nested, compact
58
- Style/ClassAndModuleChildren:
59
- Enabled: false
60
-
61
- # Offense count: 6
62
- # Cop supports --auto-correct.
63
- Style/CommentIndentation:
64
- Exclude:
65
- - 'active_model_serializers.gemspec'
66
-
67
- # Offense count: 1
68
- Style/DoubleNegation:
69
- Exclude:
70
- - 'lib/active_model/serializable_resource.rb'
71
-
72
- # Offense count: 1
73
- # Configuration parameters: MinBodyLength.
74
- Style/GuardClause:
75
- Exclude:
76
- - 'lib/active_model/serializer.rb'
77
-
78
- # Offense count: 58
79
- # Cop supports --auto-correct.
80
- # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
81
- # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
82
- Style/HashSyntax:
83
- Enabled: false
84
-
85
- # Offense count: 4
86
- # Cop supports --auto-correct.
87
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
88
- # SupportedStyles: special_inside_parentheses, consistent, align_brackets
89
- Style/IndentArray:
90
- Enabled: false
91
-
92
- # Offense count: 10
93
- # Cop supports --auto-correct.
94
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
95
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
96
- Style/IndentHash:
97
- Enabled: false
98
-
99
- # Offense count: 1
100
- # Cop supports --auto-correct.
101
- Style/Lambda:
102
- Exclude:
103
- - 'lib/active_model/serializer.rb'
104
-
105
- # Offense count: 1
106
- # Cop supports --auto-correct.
107
- # Configuration parameters: EnforcedStyle, SupportedStyles.
108
- # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
109
- Style/MethodDefParentheses:
110
- Enabled: false
111
-
112
- # Offense count: 1
113
- # Cop supports --auto-correct.
114
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
115
- # SupportedStyles: aligned, indented
116
- Style/MultilineOperationIndentation:
117
- Enabled: false
118
-
119
- # Offense count: 1
120
- # Cop supports --auto-correct.
121
- Style/NegatedIf:
122
- Exclude:
123
- - 'lib/action_controller/serialization.rb'
124
-
125
- # Offense count: 1
126
- # Cop supports --auto-correct.
127
- Style/PerlBackrefs:
128
- Exclude:
129
- - 'test/fixtures/poro.rb'
130
-
131
- # Offense count: 3
132
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
133
- # NamePrefix: is_, has_, have_
134
- # NamePrefixBlacklist: is_, has_, have_
135
- # NameWhitelist: is_a?
136
- Style/PredicateName:
137
- Exclude:
138
- - 'lib/active_model/serializer/associations.rb'
139
- - 'test/action_controller/json_api/linked_test.rb'
140
-
141
- # Offense count: 1
142
- # Cop supports --auto-correct.
143
- Style/RedundantSelf:
144
- Exclude:
145
- - 'test/fixtures/poro.rb'
146
-
147
- # Offense count: 1
148
- # Cop supports --auto-correct.
149
- # Configuration parameters: AllowIfMethodIsEmpty.
150
- Style/SingleLineMethods:
151
- Exclude:
152
- - 'test/serializers/serializer_for_test.rb'
153
-
154
- # Offense count: 4
155
- # Cop supports --auto-correct.
156
- # Configuration parameters: EnforcedStyle, SupportedStyles.
157
- # SupportedStyles: single_quotes, double_quotes
158
- Style/StringLiteralsInInterpolation:
159
- Enabled: false
160
-
161
- # Offense count: 1
162
- # Cop supports --auto-correct.
163
- # Configuration parameters: EnforcedStyle, SupportedStyles.
164
- # SupportedStyles: final_newline, final_blank_line
165
- Style/TrailingBlankLines:
166
- Exclude:
167
- - 'test/adapter/null_test.rb'