active_model_serializers 0.10.0 → 0.10.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +10 -5
  3. data/.travis.yml +41 -21
  4. data/CHANGELOG.md +200 -2
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +25 -4
  7. data/README.md +166 -28
  8. data/Rakefile +5 -32
  9. data/active_model_serializers.gemspec +23 -25
  10. data/appveyor.yml +10 -6
  11. data/bin/rubocop +38 -0
  12. data/docs/README.md +2 -1
  13. data/docs/general/adapters.md +35 -11
  14. data/docs/general/caching.md +7 -1
  15. data/docs/general/configuration_options.md +86 -1
  16. data/docs/general/deserialization.md +1 -1
  17. data/docs/general/fields.md +31 -0
  18. data/docs/general/getting_started.md +1 -1
  19. data/docs/general/logging.md +7 -0
  20. data/docs/general/rendering.md +63 -25
  21. data/docs/general/serializers.md +137 -14
  22. data/docs/howto/add_pagination_links.md +16 -17
  23. data/docs/howto/add_relationship_links.md +140 -0
  24. data/docs/howto/add_root_key.md +11 -0
  25. data/docs/howto/grape_integration.md +42 -0
  26. data/docs/howto/outside_controller_use.md +12 -4
  27. data/docs/howto/passing_arbitrary_options.md +2 -2
  28. data/docs/howto/serialize_poro.md +46 -5
  29. data/docs/howto/test.md +2 -0
  30. data/docs/howto/upgrade_from_0_8_to_0_10.md +265 -0
  31. data/docs/integrations/ember-and-json-api.md +67 -32
  32. data/docs/jsonapi/schema.md +1 -1
  33. data/lib/action_controller/serialization.rb +15 -3
  34. data/lib/active_model/serializable_resource.rb +2 -0
  35. data/lib/active_model/serializer/adapter/attributes.rb +2 -0
  36. data/lib/active_model/serializer/adapter/base.rb +4 -0
  37. data/lib/active_model/serializer/adapter/json.rb +2 -0
  38. data/lib/active_model/serializer/adapter/json_api.rb +2 -0
  39. data/lib/active_model/serializer/adapter/null.rb +2 -0
  40. data/lib/active_model/serializer/adapter.rb +2 -0
  41. data/lib/active_model/serializer/array_serializer.rb +10 -5
  42. data/lib/active_model/serializer/association.rb +64 -10
  43. data/lib/active_model/serializer/attribute.rb +2 -0
  44. data/lib/active_model/serializer/belongs_to_reflection.rb +6 -3
  45. data/lib/active_model/serializer/collection_serializer.rb +39 -13
  46. data/lib/active_model/serializer/{caching.rb → concerns/caching.rb} +87 -116
  47. data/lib/active_model/serializer/error_serializer.rb +13 -7
  48. data/lib/active_model/serializer/errors_serializer.rb +27 -20
  49. data/lib/active_model/serializer/field.rb +2 -0
  50. data/lib/active_model/serializer/fieldset.rb +2 -0
  51. data/lib/active_model/serializer/has_many_reflection.rb +5 -3
  52. data/lib/active_model/serializer/has_one_reflection.rb +3 -4
  53. data/lib/active_model/serializer/lazy_association.rb +99 -0
  54. data/lib/active_model/serializer/link.rb +23 -0
  55. data/lib/active_model/serializer/lint.rb +136 -130
  56. data/lib/active_model/serializer/null.rb +2 -0
  57. data/lib/active_model/serializer/reflection.rb +132 -67
  58. data/lib/active_model/serializer/version.rb +3 -1
  59. data/lib/active_model/serializer.rb +308 -82
  60. data/lib/active_model_serializers/adapter/attributes.rb +5 -66
  61. data/lib/active_model_serializers/adapter/base.rb +41 -39
  62. data/lib/active_model_serializers/adapter/json.rb +2 -0
  63. data/lib/active_model_serializers/adapter/json_api/deserialization.rb +4 -2
  64. data/lib/active_model_serializers/adapter/json_api/error.rb +2 -0
  65. data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +2 -0
  66. data/lib/active_model_serializers/adapter/json_api/link.rb +3 -1
  67. data/lib/active_model_serializers/adapter/json_api/meta.rb +2 -0
  68. data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +49 -21
  69. data/lib/active_model_serializers/adapter/json_api/relationship.rb +77 -23
  70. data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +41 -10
  71. data/lib/active_model_serializers/adapter/json_api.rb +84 -65
  72. data/lib/active_model_serializers/adapter/null.rb +2 -0
  73. data/lib/active_model_serializers/adapter.rb +9 -1
  74. data/lib/active_model_serializers/callbacks.rb +2 -0
  75. data/lib/active_model_serializers/deprecate.rb +3 -2
  76. data/lib/active_model_serializers/deserialization.rb +4 -0
  77. data/lib/active_model_serializers/json_pointer.rb +2 -0
  78. data/lib/active_model_serializers/logging.rb +2 -0
  79. data/lib/active_model_serializers/lookup_chain.rb +82 -0
  80. data/lib/active_model_serializers/model.rb +111 -28
  81. data/lib/active_model_serializers/railtie.rb +7 -1
  82. data/lib/active_model_serializers/register_jsonapi_renderer.rb +46 -31
  83. data/lib/active_model_serializers/serializable_resource.rb +10 -7
  84. data/lib/active_model_serializers/serialization_context.rb +12 -3
  85. data/lib/active_model_serializers/test/schema.rb +4 -2
  86. data/lib/active_model_serializers/test/serializer.rb +2 -0
  87. data/lib/active_model_serializers/test.rb +2 -0
  88. data/lib/active_model_serializers.rb +35 -10
  89. data/lib/generators/rails/resource_override.rb +3 -1
  90. data/lib/generators/rails/serializer_generator.rb +6 -4
  91. data/lib/grape/active_model_serializers.rb +9 -5
  92. data/lib/grape/formatters/active_model_serializers.rb +21 -2
  93. data/lib/grape/helpers/active_model_serializers.rb +3 -0
  94. data/lib/tasks/rubocop.rake +55 -0
  95. data/test/action_controller/adapter_selector_test.rb +16 -5
  96. data/test/action_controller/explicit_serializer_test.rb +7 -4
  97. data/test/action_controller/json/include_test.rb +108 -27
  98. data/test/action_controller/json_api/deserialization_test.rb +3 -1
  99. data/test/action_controller/json_api/errors_test.rb +10 -9
  100. data/test/action_controller/json_api/fields_test.rb +68 -0
  101. data/test/action_controller/json_api/linked_test.rb +31 -24
  102. data/test/action_controller/json_api/pagination_test.rb +33 -23
  103. data/test/action_controller/json_api/transform_test.rb +13 -3
  104. data/test/action_controller/lookup_proc_test.rb +51 -0
  105. data/test/action_controller/namespace_lookup_test.rb +234 -0
  106. data/test/action_controller/serialization_scope_name_test.rb +14 -6
  107. data/test/action_controller/serialization_test.rb +23 -12
  108. data/test/active_model_serializers/adapter_for_test.rb +2 -0
  109. data/test/active_model_serializers/json_pointer_test.rb +17 -13
  110. data/test/active_model_serializers/logging_test.rb +2 -0
  111. data/test/active_model_serializers/model_test.rb +139 -4
  112. data/test/active_model_serializers/railtie_test_isolated.rb +14 -7
  113. data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +163 -0
  114. data/test/active_model_serializers/serialization_context_test_isolated.rb +25 -10
  115. data/test/active_model_serializers/test/schema_test.rb +5 -2
  116. data/test/active_model_serializers/test/serializer_test.rb +2 -0
  117. data/test/active_record_test.rb +2 -0
  118. data/test/adapter/attributes_test.rb +42 -0
  119. data/test/adapter/deprecation_test.rb +2 -0
  120. data/test/adapter/json/belongs_to_test.rb +2 -0
  121. data/test/adapter/json/collection_test.rb +16 -0
  122. data/test/adapter/json/has_many_test.rb +12 -2
  123. data/test/adapter/json/transform_test.rb +17 -15
  124. data/test/adapter/json_api/belongs_to_test.rb +2 -0
  125. data/test/adapter/json_api/collection_test.rb +6 -3
  126. data/test/adapter/json_api/errors_test.rb +19 -19
  127. data/test/adapter/json_api/fields_test.rb +14 -3
  128. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +2 -0
  129. data/test/adapter/json_api/has_many_test.rb +51 -20
  130. data/test/adapter/json_api/has_one_test.rb +2 -0
  131. data/test/adapter/json_api/include_data_if_sideloaded_test.rb +215 -0
  132. data/test/adapter/json_api/json_api_test.rb +7 -7
  133. data/test/adapter/json_api/linked_test.rb +35 -12
  134. data/test/adapter/json_api/links_test.rb +22 -3
  135. data/test/adapter/json_api/pagination_links_test.rb +55 -13
  136. data/test/adapter/json_api/parse_test.rb +3 -1
  137. data/test/adapter/json_api/relationship_test.rb +311 -73
  138. data/test/adapter/json_api/resource_meta_test.rb +5 -3
  139. data/test/adapter/json_api/toplevel_jsonapi_test.rb +2 -0
  140. data/test/adapter/json_api/transform_test.rb +265 -253
  141. data/test/adapter/json_api/type_test.rb +170 -36
  142. data/test/adapter/json_test.rb +10 -7
  143. data/test/adapter/null_test.rb +3 -2
  144. data/test/adapter/polymorphic_test.rb +54 -5
  145. data/test/adapter_test.rb +3 -1
  146. data/test/array_serializer_test.rb +2 -0
  147. data/test/benchmark/app.rb +3 -1
  148. data/test/benchmark/benchmarking_support.rb +3 -1
  149. data/test/benchmark/bm_active_record.rb +83 -0
  150. data/test/benchmark/bm_adapter.rb +40 -0
  151. data/test/benchmark/bm_caching.rb +18 -16
  152. data/test/benchmark/bm_lookup_chain.rb +85 -0
  153. data/test/benchmark/bm_transform.rb +23 -10
  154. data/test/benchmark/controllers.rb +18 -17
  155. data/test/benchmark/fixtures.rb +74 -72
  156. data/test/cache_test.rb +301 -69
  157. data/test/collection_serializer_test.rb +33 -14
  158. data/test/fixtures/active_record.rb +47 -10
  159. data/test/fixtures/poro.rb +128 -183
  160. data/test/generators/scaffold_controller_generator_test.rb +2 -0
  161. data/test/generators/serializer_generator_test.rb +25 -5
  162. data/test/grape_test.rb +172 -56
  163. data/test/lint_test.rb +3 -1
  164. data/test/logger_test.rb +15 -11
  165. data/test/poro_test.rb +2 -0
  166. data/test/serializable_resource_test.rb +20 -22
  167. data/test/serializers/association_macros_test.rb +5 -2
  168. data/test/serializers/associations_test.rb +274 -49
  169. data/test/serializers/attribute_test.rb +7 -3
  170. data/test/serializers/attributes_test.rb +3 -1
  171. data/test/serializers/caching_configuration_test_isolated.rb +8 -6
  172. data/test/serializers/configuration_test.rb +2 -0
  173. data/test/serializers/fieldset_test.rb +3 -1
  174. data/test/serializers/meta_test.rb +14 -6
  175. data/test/serializers/options_test.rb +19 -6
  176. data/test/serializers/read_attribute_for_serialization_test.rb +5 -3
  177. data/test/serializers/reflection_test.rb +481 -0
  178. data/test/serializers/root_test.rb +3 -1
  179. data/test/serializers/serialization_test.rb +4 -2
  180. data/test/serializers/serializer_for_test.rb +14 -10
  181. data/test/serializers/serializer_for_with_namespace_test.rb +90 -0
  182. data/test/support/isolated_unit.rb +11 -4
  183. data/test/support/rails5_shims.rb +10 -2
  184. data/test/support/rails_app.rb +4 -9
  185. data/test/support/serialization_testing.rb +33 -5
  186. data/test/test_helper.rb +15 -0
  187. metadata +126 -46
  188. data/.rubocop_todo.yml +0 -167
  189. data/docs/ARCHITECTURE.md +0 -126
  190. data/lib/active_model/serializer/associations.rb +0 -100
  191. data/lib/active_model/serializer/attributes.rb +0 -82
  192. data/lib/active_model/serializer/collection_reflection.rb +0 -7
  193. data/lib/active_model/serializer/configuration.rb +0 -35
  194. data/lib/active_model/serializer/include_tree.rb +0 -111
  195. data/lib/active_model/serializer/links.rb +0 -35
  196. data/lib/active_model/serializer/meta.rb +0 -29
  197. data/lib/active_model/serializer/singular_reflection.rb +0 -7
  198. data/lib/active_model/serializer/type.rb +0 -25
  199. data/lib/active_model_serializers/key_transform.rb +0 -70
  200. data/test/active_model_serializers/key_transform_test.rb +0 -263
  201. data/test/adapter/json_api/has_many_embed_ids_test.rb +0 -43
  202. data/test/adapter/json_api/relationships_test.rb +0 -199
  203. data/test/adapter/json_api/resource_identifier_test.rb +0 -85
  204. data/test/include_tree/from_include_args_test.rb +0 -26
  205. data/test/include_tree/from_string_test.rb +0 -94
  206. data/test/include_tree/include_args_to_hash_test.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eb97c8740c2530c085ee9186ea27ddd220367fc3
4
- data.tar.gz: 0a768d3ab122abe2c3e7f5b6c00a8dada6872433
2
+ SHA256:
3
+ metadata.gz: e365d9b8e66fd40b66555a2e57faad48fee5bfd82b988ab42aacda73930bb53c
4
+ data.tar.gz: bbad118b340ea31c7a09f1f0661d0e53866135a99923276182dc159d4eeb2f9c
5
5
  SHA512:
6
- metadata.gz: 5589022dd6fa160c0a03981cedf46433fb1eb19e4bac5f3489908671e9e0969c48bb7a86cf03d12cf8ce825b2efe3ed6ad1b6594019635470319c899e7964617
7
- data.tar.gz: 989cf413780f12d47a553a7aae5cba33de1625bbc022366b7e4533810b87b151302ed6000116c03234bf2b2048a913048624728a54be87cead848076924cf6ce
6
+ metadata.gz: 011fcf63a00a7cfc27a54679551cf6c03b3dd4ff177192fca7d2be34bfbb2c3b6c6ba40bc92395997a392ed9bf1d91823da15afa7bde374d08f5e9d69982d054
7
+ data.tar.gz: 8311b1ed270c60ae5d00beaa2e421a350201bec131a44096190f40dfb61a84f11d50ace18c357cc77e364863bef94eebaad717dc78a156c923049679c5295d1d
data/.rubocop.yml CHANGED
@@ -1,12 +1,13 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  AllCops:
4
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.1
5
3
  Exclude:
6
- - config/initializers/forbidden_yaml.rb
7
4
  - !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
8
5
  DisplayCopNames: true
9
6
  DisplayStyleGuide: true
7
+ # https://github.com/bbatsov/rubocop/blob/master/manual/caching.md
8
+ # https://github.com/bbatsov/rubocop/blob/e8680418b351491e111a18cf5b453fc07a3c5239/config/default.yml#L60-L77
9
+ UseCache: true
10
+ CacheRootDirectory: tmp
10
11
 
11
12
  Rails:
12
13
  Enabled: true
@@ -46,7 +47,7 @@ Style/AlignParameters:
46
47
  EnforcedStyle: with_fixed_indentation
47
48
 
48
49
  Style/ClassAndModuleChildren:
49
- EnforcedStyle: compact
50
+ EnforcedStyle: nested
50
51
 
51
52
  Style/Documentation:
52
53
  Enabled: false
@@ -58,6 +59,10 @@ Style/MissingElse:
58
59
  Style/EmptyElse:
59
60
  EnforcedStyle: empty
60
61
 
62
+ Style/FrozenStringLiteralComment:
63
+ Enabled: true
64
+ EnforcedStyle: always
65
+
61
66
  Style/MultilineOperationIndentation:
62
67
  EnforcedStyle: indented
63
68
 
data/.travis.yml CHANGED
@@ -1,43 +1,63 @@
1
1
  language: ruby
2
-
3
2
  sudo: false
4
3
 
5
- rvm:
6
- - 2.1
7
- - 2.2.3
8
- - 2.3.0
9
- - ruby-head
10
- - jruby-9.0.4.0
11
- - jruby-head
12
-
13
- jdk:
14
- - oraclejdk8
15
-
16
- install: bundle install --path=vendor/bundle --retry=3 --jobs=3
17
4
  cache:
18
5
  directories:
19
6
  - vendor/bundle
20
7
 
8
+ before_install:
9
+ - "travis_retry gem update --system 2.7.8"
10
+ - "travis_retry gem install bundler -v '1.17.3'"
11
+ install: BUNDLER_VERSION=1.17.3 bundle install --path=vendor/bundle --retry=3 --jobs=3
12
+
21
13
  script:
22
14
  - bundle exec rake ci
15
+ after_success:
16
+ - codeclimate-test-reporter
23
17
 
24
18
  env:
25
- global:
26
- - "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
27
19
  matrix:
28
20
  - "RAILS_VERSION=4.1"
29
21
  - "RAILS_VERSION=4.2"
22
+ - "RAILS_VERSION=5.0"
23
+ - "RAILS_VERSION=5.1"
24
+ - "RAILS_VERSION=5.2"
30
25
  - "RAILS_VERSION=master"
31
26
 
27
+ rvm:
28
+ - 2.1.10
29
+ - 2.2.8
30
+ - 2.3.5
31
+ - 2.4.2
32
+ - 2.5.3
33
+ - ruby-head
34
+
35
+ branches:
36
+ only:
37
+ - 0-10-stable
38
+
32
39
  matrix:
40
+ include:
41
+ - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
42
+ - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
43
+ - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
44
+ # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
45
+ # - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
46
+ # - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
33
47
  exclude:
34
- - rvm: 2.1
35
- env: RAILS_VERSION=master
36
- - rvm: jruby-9.0.4.0
37
- env: RAILS_VERSION=master
38
- - rvm: jruby-head
39
- env: RAILS_VERSION=master
48
+ - { rvm: 2.1.10, env: RAILS_VERSION=master }
49
+ - { rvm: 2.2.8, env: RAILS_VERSION=master }
50
+ - { rvm: 2.3.5, env: RAILS_VERSION=master }
51
+ - { rvm: 2.4.2, env: RAILS_VERSION=master }
52
+ - { rvm: 2.1.10, env: RAILS_VERSION=5.0 }
53
+ - { rvm: 2.1.10, env: RAILS_VERSION=5.1 }
54
+ - { rvm: 2.1.10, env: RAILS_VERSION=5.2 }
55
+ - { rvm: 2.4.2, env: RAILS_VERSION=4.1 }
56
+ - { rvm: 2.5.3, env: RAILS_VERSION=4.1 }
57
+ - { rvm: ruby-head, env: RAILS_VERSION=4.1 }
40
58
  allow_failures:
41
59
  - rvm: ruby-head
42
60
  - rvm: jruby-head
61
+ # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
62
+ - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
43
63
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,8 +1,205 @@
1
1
  ## 0.10.x
2
2
 
3
- ### [master (unreleased)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0...master)
3
+ ### [master (unreleased)](https://github.com/rails-api/active_model_serializers/compare/v0.10.9...0-10-stable)
4
4
 
5
- ### v0.10.0 (2016-05-17)
5
+ Breaking changes:
6
+
7
+ Features:
8
+
9
+ Fixes:
10
+
11
+ Misc:
12
+
13
+ ### [v0.10.9 (2019-02-08)](https://github.com/rails-api/active_model_serializers/compare/v0.10.8...v0.10.9)
14
+
15
+
16
+ Fixes:
17
+
18
+ - [#2288](https://github.com/rails-api/active_model_serializers/pull/2288)
19
+ Change the fetch method to deal with recyclable key cache strategy.
20
+ Fixes #2287. (@cintamani, @wasifhossain)
21
+ - [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.
22
+
23
+ Misc:
24
+
25
+ - [#2309](https://github.com/rails-api/active_model_serializers/pull/2309) Performance and memory usage fixes
26
+
27
+ ### [v0.10.8 (2018-11-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.7...v0.10.8)
28
+
29
+ Features:
30
+ - [#2279](https://github.com/rails-api/active_model_serializers/pull/2279) Support condition options in serializer link statements
31
+
32
+ Fixes:
33
+
34
+ - [#2296](https://github.com/rails-api/active_model_serializers/pull/2296) Fixes #2295 (@Hirurg103)
35
+ - Fix finding of namespaced serializer and non-namespaced model.
36
+ - [#2289](https://github.com/rails-api/active_model_serializers/pull/2289) Fixes #2255 (@f-mer)
37
+ - Fix autoloading race condition, especially in Rails 5.
38
+ - [#2299](https://github.com/rails-api/active_model_serializers/pull/2299) Fixes #2270 (@chau-bao-long via #2276)
39
+ - Fix reflection thread-safety bug
40
+
41
+ ### [v0.10.7 (2017-11-14)](https://github.com/rails-api/active_model_serializers/compare/v0.10.6...v0.10.7)
42
+
43
+ Regressions Fixed From v0.10.6:
44
+
45
+ - [#2211](https://github.com/rails-api/active_model_serializers/pull/2211). Fixes #2125, #2160. (@bf4)
46
+ - Fix polymorphic belongs_to tests; passes on v0.10.5, fails on v0.10.6
47
+ - Fix JSON:API polymorphic type regression from v0.10.5
48
+ - Fix JSON:API: for_type_and_id should always inflect_type
49
+ ```
50
+ Should Serializer._type ever be inflected?
51
+ Right now, it won't be, but association.serializer._type will be inflected.
52
+
53
+ That's the current behavior.
54
+ ```
55
+ - [#2216](https://github.com/rails-api/active_model_serializers/pull/2216). Fixes #2132, #2180. (@bf4)
56
+ - Fix JSON:API: Serialize resource type for unpersisted records (blank id)
57
+ - [#2218](https://github.com/rails-api/active_model_serializers/pull/2218). Fixes #2178. (@bf4)
58
+ - Fix JSON:API: Make using foreign key on belongs_to opt-in. No effect on polymorphic relationships.
59
+ ```
60
+ # set to true to opt-in
61
+ ActiveModelSerializer.config.jsonapi_use_foreign_key_on_belongs_to_relationship = true
62
+ ```
63
+
64
+ Features:
65
+
66
+ - [#2136](https://github.com/rails-api/active_model_serializers/pull/2136) Enable inclusion of sideloaded relationship objects by `key`. (@caomania)
67
+ - [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) ActiveModelSerializers::Model#attributes. Originally in [#1982](https://github.com/rails-api/active_model_serializers/pull/1982). (@bf4)
68
+ - [#2130](https://github.com/rails-api/active_model_serializers/pull/2130) Allow serialized ID to be overwritten for belongs-to relationships. (@greysteil)
69
+ - [#2189](https://github.com/rails-api/active_model_serializers/pull/2189)
70
+ Update version constraint for jsonapi-renderer to `['>= 0.1.1.beta1', '< 0.3']`
71
+ (@tagliala)
72
+
73
+ Fixes:
74
+
75
+ - [#2022](https://github.com/rails-api/active_model_serializers/pull/2022) Mutation of ActiveModelSerializers::Model now changes the attributes. Originally in [#1984](https://github.com/rails-api/active_model_serializers/pull/1984). (@bf4)
76
+ - [#2200](https://github.com/rails-api/active_model_serializers/pull/2200) Fix deserialization of polymorphic relationships. (@dennis95stumm)
77
+ - [#2214](https://github.com/rails-api/active_model_serializers/pull/2214) Fail if unable to infer collection type with json adapter. (@jmeredith16)
78
+ - [#2149](https://github.com/rails-api/active_model_serializers/pull/2149) Always include self, first, last pagination link. (@mecampbellsoup)
79
+ - [#2179](https://github.com/rails-api/active_model_serializers/pull/2179) Fixes #2173, Pass block to Enumerator.new. (@drn)
80
+
81
+ Misc:
82
+
83
+ - [#2176](https://github.com/rails-api/active_model_serializers/pull/2176) Documentation for global adapter config. (@mrpinsky)
84
+ - [#2215](https://github.com/rails-api/active_model_serializers/pull/2215) Update `serializers.md` documentation to denote alternate use cases for `scope`. (@stratigos)
85
+ - [#2212](https://github.com/rails-api/active_model_serializers/pull/2212) Remove legacy has_many_embed_ids test. (@bf4)
86
+
87
+ ### [v0.10.6 (2017-05-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.5...v0.10.6)
88
+
89
+ Fixes:
90
+
91
+ - [#1857](https://github.com/rails-api/active_model_serializers/pull/1857) JSON:API does not load belongs_to relation to get identifier id. (@bf4)
92
+ - [#2119](https://github.com/rails-api/active_model_serializers/pull/2119) JSON:API returns null resource object identifier when 'id' is null. (@bf4)
93
+ - [#2093](https://github.com/rails-api/active_model_serializers/pull/2093) undef problematic Serializer methods: display, select. (@bf4)
94
+
95
+ Misc:
96
+
97
+ - [#2104](https://github.com/rails-api/active_model_serializers/pull/2104) Documentation for serializers and rendering. (@cassidycodes)
98
+ - [#2081](https://github.com/rails-api/active_model_serializers/pull/2081) Documentation for `include` option in adapters. (@charlie-wasp)
99
+ - [#2120](https://github.com/rails-api/active_model_serializers/pull/2120) Documentation for association options: foreign_key, type, class_name, namespace. (@bf4)
100
+
101
+ ### [v0.10.5 (2017-03-07)](https://github.com/rails-api/active_model_serializers/compare/v0.10.4...v0.10.5)
102
+
103
+ Breaking changes:
104
+
105
+ Features:
106
+
107
+ - [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) ActiveModelSerializers::Model#attributes. Originally in [#1982](https://github.com/rails-api/active_model_serializers/pull/1982). (@bf4)
108
+ - [#2057](https://github.com/rails-api/active_model_serializers/pull/2057)
109
+ Update version constraint for jsonapi-renderer to `['>= 0.1.1.beta1', '< 0.2']`
110
+ (@jaredbeck)
111
+
112
+ Fixes:
113
+
114
+ - [#2022](https://github.com/rails-api/active_model_serializers/pull/2022) Mutation of ActiveModelSerializers::Model now changes the attributes. Originally in [#1984](https://github.com/rails-api/active_model_serializers/pull/1984). (@bf4)
115
+
116
+ Misc:
117
+
118
+ - [#2055](https://github.com/rails-api/active_model_serializers/pull/2055)
119
+ Replace deprecated dependency jsonapi with jsonapi-renderer. (@jaredbeck)
120
+ - [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4)
121
+ - [#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh)
122
+ - [#2035](https://github.com/rails-api/active_model_serializers/pull/2035) Document how to disable the logger. (@MSathieu)
123
+ - [#2039](https://github.com/rails-api/active_model_serializers/pull/2039) Documentation fixes. (@biow0lf)
124
+
125
+ ### [v0.10.4 (2017-01-06)](https://github.com/rails-api/active_model_serializers/compare/v0.10.3...v0.10.4)
126
+
127
+ Misc:
128
+
129
+ - [#2005](https://github.com/rails-api/active_model_serializers/pull/2005) Update jsonapi runtime dependency to 0.1.1.beta6, support Ruby 2.4. (@kofronpi)
130
+ - [#1993](https://github.com/rails-api/active_model_serializers/pull/1993) Swap out KeyTransform for CaseTransform gem for the possibility of native extension use. (@NullVoxPopuli)
131
+
132
+ ### [v0.10.3 (2016-11-21)](https://github.com/rails-api/active_model_serializers/compare/v0.10.2...v0.10.3)
133
+
134
+ Fixes:
135
+
136
+ - [#1973](https://github.com/rails-api/active_model_serializers/pull/1973) Fix namespace lookup for collections and has_many relationships (@groyoh)
137
+ - [#1887](https://github.com/rails-api/active_model_serializers/pull/1887) Make the comment reflect what the function does (@johnnymo87)
138
+ - [#1890](https://github.com/rails-api/active_model_serializers/issues/1890) Ensure generator inherits from ApplicationSerializer when available (@richmolj)
139
+ - [#1922](https://github.com/rails-api/active_model_serializers/pull/1922) Make railtie an optional dependency in runtime (@ggpasqualino)
140
+ - [#1930](https://github.com/rails-api/active_model_serializers/pull/1930) Ensure valid jsonapi when relationship has no links or data (@richmolj)
141
+
142
+ Features:
143
+
144
+ - [#1757](https://github.com/rails-api/active_model_serializers/pull/1757) Make serializer lookup chain configurable. (@NullVoxPopuli)
145
+ - [#1968](https://github.com/rails-api/active_model_serializers/pull/1968) (@NullVoxPopuli)
146
+ - Add controller namespace to default controller lookup
147
+ - Provide a `namespace` render option
148
+ - document how set the namespace in the controller for implicit lookup.
149
+ - [#1791](https://github.com/rails-api/active_model_serializers/pull/1791) (@bf4, @youroff, @NullVoxPopuli)
150
+ - Added `jsonapi_namespace_separator` config option.
151
+ - [#1889](https://github.com/rails-api/active_model_serializers/pull/1889) Support key transformation for Attributes adapter (@iancanderson, @danbee)
152
+ - [#1917](https://github.com/rails-api/active_model_serializers/pull/1917) Add `jsonapi_pagination_links_enabled` configuration option (@richmolj)
153
+ - [#1797](https://github.com/rails-api/active_model_serializers/pull/1797) Only include 'relationships' when sideloading (@richmolj)
154
+
155
+ Fixes:
156
+
157
+ - [#1833](https://github.com/rails-api/active_model_serializers/pull/1833) Remove relationship links if they are null (@groyoh)
158
+ - [#1881](https://github.com/rails-api/active_model_serializers/pull/1881) ActiveModelSerializers::Model correctly works with string keys (@yevhene)
159
+
160
+ Misc:
161
+ - [#1767](https://github.com/rails-api/active_model_serializers/pull/1767) Replace raising/rescuing `CollectionSerializer::NoSerializerError`,
162
+ throw/catch `:no_serializer`. (@bf4)
163
+ - [#1839](https://github.com/rails-api/active_model_serializers/pull/1839) `fields` tests demonstrating usage for both attributes and relationships. (@NullVoxPopuli)
164
+ - [#1812](https://github.com/rails-api/active_model_serializers/pull/1812) add a code of conduct (@corainchicago)
165
+
166
+ - [#1878](https://github.com/rails-api/active_model_serializers/pull/1878) Cache key generation for serializers now uses `ActiveSupport::Cache.expand_cache_key` instead of `Array#join` by default and is also overridable. This change should be backward-compatible. (@markiz)
167
+
168
+ - [#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@cassidycodes)
169
+ - [#1909](https://github.com/rails-api/active_model_serializers/pull/1909) Add documentation for relationship links. (@vasilakisfil, @NullVoxPopuli)
170
+ - [#1959](https://github.com/rails-api/active_model_serializers/pull/1959) Add documentation for root. (@shunsuke227ono)
171
+ - [#1967](https://github.com/rails-api/active_model_serializers/pull/1967) Improve type method documentation. (@yukideluxe)
172
+
173
+ ### [v0.10.2 (2016-07-05)](https://github.com/rails-api/active_model_serializers/compare/v0.10.1...v0.10.2)
174
+
175
+ Fixes:
176
+ - [#1814](https://github.com/rails-api/active_model_serializers/pull/1814) Ensuring read_multi works with fragment cache
177
+ - [#1848](https://github.com/rails-api/active_model_serializers/pull/1848) Redefine associations on inherited serializers. (@EhsanYousefi)
178
+
179
+ Misc:
180
+ - [#1808](https://github.com/rails-api/active_model_serializers/pull/1808) Adds documentation for `fields` option. (@luizkowalski)
181
+
182
+ ### [v0.10.1 (2016-06-16)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0...v0.10.1)
183
+
184
+ Features:
185
+ - [#1668](https://github.com/rails-api/active_model_serializers/pull/1668) Exclude nil and empty links. (@sigmike)
186
+ - [#1426](https://github.com/rails-api/active_model_serializers/pull/1426) Add ActiveModelSerializers.config.default_includes (@empact)
187
+
188
+ Fixes:
189
+ - [#1754](https://github.com/rails-api/active_model_serializers/pull/1754) Fixes #1759, Grape integration, improves serialization_context
190
+ missing error message on pagination. Document overriding CollectionSerializer#paginated?. (@bf4)
191
+ Moved serialization_context creation to Grape formatter, so resource serialization works without explicit calls to the `render` helper method.
192
+ Added Grape collection tests. (@onomated)
193
+ - [#1287](https://github.com/rails-api/active_model_serializers/pull/1287) Pass `fields` options from adapter to serializer. (@vasilakisfil)
194
+ - [#1710](https://github.com/rails-api/active_model_serializers/pull/1710) Prevent association loading when `include_data` option
195
+ is set to `false`. (@groyoh)
196
+ - [#1747](https://github.com/rails-api/active_model_serializers/pull/1747) Improve jsonapi mime type registration for Rails 5 (@remear)
197
+
198
+ Misc:
199
+ - [#1734](https://github.com/rails-api/active_model_serializers/pull/1734) Adds documentation for conditional attribute (@lambda2)
200
+ - [#1685](https://github.com/rails-api/active_model_serializers/pull/1685) Replace `IncludeTree` with `IncludeDirective` from the jsonapi gem.
201
+
202
+ ### [v0.10.0 (2016-05-17)](https://github.com/rails-api/active_model_serializers/compare/4a2d9853ba7...v0.10.0)
6
203
 
7
204
  Breaking changes:
8
205
  - [#1662](https://github.com/rails-api/active_model_serializers/pull/1662) Drop support for Rails 4.0 and Ruby 2.0.0. (@remear)
@@ -22,6 +219,7 @@ Fixes:
22
219
 
23
220
  Misc:
24
221
  - [#1673](https://github.com/rails-api/active_model_serializers/pull/1673) Adds "How to" guide on using AMS with POROs (@DrSayre)
222
+ - [#1730](https://github.com/rails-api/active_model_serializers/pull/1730) Adds documentation for overriding default serializer based on conditions (@groyoh/@cgmckeever)
25
223
 
26
224
  ### [v0.10.0.rc5 (2016-04-04)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0.rc4...v0.10.0.rc5)
27
225
 
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting one of the owners listed at https://rubygems.org/gems/active_model_serializers. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  #
3
5
  # Add a Gemfile.local to locally bundle gems outside of version control
@@ -12,6 +14,7 @@ version = ENV['RAILS_VERSION'] || '4.2'
12
14
  if version == 'master'
13
15
  gem 'rack', github: 'rack/rack'
14
16
  gem 'arel', github: 'rails/arel'
17
+ gem 'rails', github: 'rails/rails'
15
18
  git 'https://github.com/rails/rails.git' do
16
19
  gem 'railties'
17
20
  gem 'activesupport'
@@ -23,6 +26,7 @@ if version == 'master'
23
26
  end
24
27
  else
25
28
  gem_version = "~> #{version}.0"
29
+ gem 'rails', gem_version
26
30
  gem 'railties', gem_version
27
31
  gem 'activesupport', gem_version
28
32
  gem 'activemodel', gem_version
@@ -36,18 +40,35 @@ end
36
40
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
37
41
  gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
38
42
 
43
+ if ENV['CI']
44
+ if RUBY_VERSION < '2.4'
45
+ # Windows: An error occurred while installing nokogiri (1.8.0)
46
+ gem 'nokogiri', '< 1.7', platforms: @windows_platforms
47
+ end
48
+ end
49
+
39
50
  group :bench do
40
51
  # https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76
41
- gem 'benchmark-ips', require: false, group: :development
52
+ gem 'benchmark-ips', '>= 2.7.2', require: false, group: :development
42
53
  end
43
54
 
44
55
  group :test do
45
- gem 'sqlite3', platform: (@windows_platforms + [:ruby])
46
- gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
56
+ gem 'sqlite3', '~> 1.3.13', platform: (@windows_platforms + [:ruby])
57
+ platforms :jruby do
58
+ if version == 'master' || version >= '5'
59
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 50'
60
+ else
61
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3.0'
62
+ end
63
+ end
47
64
  gem 'codeclimate-test-reporter', require: false
65
+ gem 'm', '~> 1.5'
66
+ gem 'pry', '>= 0.10'
67
+ gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2'
68
+ gem 'pry-byebug', platform: :ruby
48
69
  end
49
70
 
50
71
  group :development, :test do
51
- gem 'rubocop', '~> 0.39.0', require: false
72
+ gem 'rubocop', '~> 0.40.0', require: false
52
73
  gem 'yard', require: false
53
74
  end