Benjamin Fleischer
dcbe4ef9e2
Rubocop autocorrect indentation
2016-02-08 17:39:45 -06:00
Benjamin Fleischer
e51597480a
Merge branch 'beauby-association-blocks'
...
Has Rubocop failures to be fixed in next commit.
2016-02-08 17:37:31 -06:00
Benjamin Fleischer
72c2c9f0d7
Merge pull request #1447 from beauby/jsonapi-refactor-2016
...
[PERF] Refactor JsonApi adapter to avoid redundant computations.
2016-02-02 10:10:47 -06:00
João M. D. Moura
58ff7535b7
releaseing new version RC4
2016-01-27 10:03:01 -05:00
Alexandre de Oliveira
ef58efdf73
Merge pull request #1418 from brigade/collection-pluralize
...
Don't pluralize the CollectionSerializer#root for #json_key
2016-01-25 19:46:47 -02:00
Lucas Hosseini
061f1c0f59
Add support for relationship-level links and meta.
2016-01-21 02:36:54 +01:00
Lucas Hosseini
20ddc5e102
Refactor JsonApi adapter to avoid redundant computations.
2016-01-20 00:31:22 +01:00
Benjamin Fleischer
8981683b9f
Merge pull request #1352 from bf4/railties
...
Fix generators (@dgynn); load Railtie only with Rails, ensures caching configured
2016-01-18 23:24:40 -05:00
Lucas Hosseini
30d8414cce
Add support for dynamic string-links in JsonApi adapter.
2016-01-15 14:36:42 +01:00
Benjamin Fleischer
0c2153ac5e
Collect more Rails initialization code in the Railtie
2016-01-15 01:52:27 -06:00
Benjamin Fleischer
87ca408ead
Merge pull request #1425 from beauby/extract-serializer-modules
...
[CLEANUP] Extract links and type-related methods to their own module.
2016-01-15 00:56:40 -06:00
Mauro George
5058694f4a
Create assert_response_schema test helper
...
It is a common pattern to use JSON Schema to validate a API response[1], [2]
and [3].
This patch creates the `assert_response_schema` test helper that helps people do
this kind of validation easily on the controller tests.
[1]: https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher
[2]: https://github.com/sharethrough/json-schema-rspec
[3]: https://github.com/rails-api/active_model_serializers/issues/1011#issuecomment-127608121
2016-01-15 00:45:56 -06:00
Mauro George
c0b99c980c
Bring back assert_serializer for controller testing
...
The `assert_serializer` test helper was added in 0.9.0.apha1[1],
and was not included in 0.10.
This patch brings back the `assert_serializer` test helper. This is the last
revision[2] that has the helper. The original helper was used as base.
[1]: https://github.com/rails-api/active_model_serializers/pull/596
[2]: 610aeb2e92
- Create the AssertSerializer
- Use the Test namespace
- Make the tests pass on the Rails master
- Rails 5 does not include `assert_template` but we need this on the tests of
the helper.
- This add the `rails-controller-testing` to keep support on `assert_template`.
- Only load test helpers in the test environment
2016-01-13 20:54:22 -06:00
Lucas Hosseini
2696557650
Replace Field#included? with Field#excluded?.
2016-01-13 06:20:05 +01:00
Chris Nixon
7fbf7e536d
Use condition_type in case statement for included?.
2016-01-13 06:20:05 +01:00
Lucas Hosseini
40ed7b57bd
Factor out ancestor class Field of Attribute and Reflection.
2016-01-13 06:20:04 +01:00
Lucas Hosseini
6860318133
Add support for if/unless on associations.
2016-01-13 06:19:47 +01:00
Lucas Hosseini
a502b5d38b
Add support for if/unless on attributes.
2016-01-13 06:19:28 +01:00
Lucas Hosseini
adaf5b87df
Merge pull request #1248 from beauby/jsonapi-parse
...
JSON API deserialization.
2016-01-13 06:18:52 +01:00
Lucas Hosseini
20a58d7f5c
Add support for JSON API deserialization (experimental).
2016-01-13 05:48:06 +01:00
Lucas Hosseini
2e87c8effe
Fix comment.
2016-01-13 05:41:32 +01:00
Ben Woosley
8ac1f107f4
Remove unnecessary dup in ActiveModel::Serializer::Associations#associate
...
The `_reflections` are duped on `inherited` - no need to `dup` them
with each addition.
2016-01-12 14:42:07 -08:00
Ben Woosley
251e33a0a1
Don't pluralize the CollectionSerializer#root for #json_key
...
One of three constituents is used to provide the
CollectionSerializer's #json_key:
1) the :root option - controlled by the caller
2) the #name of the first resource serializer - the root or
underscored model name
3) the underscored #name of the resources object - generally
equivalent to the underscored model name of #2
Of the three, only the latter 2 are out of the callers control, and
only the latter two are expected to be singular by default. Not
pluralizing the root gives the caller additional flexibility in
defining the desired root, whether conventionally plural,
unconventionally plural (e.g. objects_received:) or singular.
2016-01-12 09:32:43 -08:00
Lucas Hosseini
f6fe0c8aa3
Extract links and type-related methods to their own module.
2016-01-12 15:05:39 +01:00
Ben Woosley
0a6c133d25
Tidy up the tests
...
* Use assert_nil where appropriate
* Lead with the expected value in collection_serializer_test.rb, etc
so that expected/actual in test failure messages are not reversed
2016-01-07 11:21:19 -08:00
Benjamin Fleischer
7d4f0c5c8a
Merge branch 'bf4-consider_association_blocks'
2016-01-03 23:16:49 -06:00
Lucas Hosseini
77095f2a84
Add ActiveSupport::Autoload extension to Attribute.
2015-12-30 17:44:19 +01:00
Lucas Hosseini
a586a45863
Remove key from Attribute class.
2015-12-30 16:47:10 +01:00
Lucas Hosseini
7d24cbfd3d
Extract latent Attribute object.
2015-12-30 16:47:10 +01:00
Lucas Hosseini
1d4b27f60f
Improve attribute value computation.
2015-12-30 16:47:10 +01:00
Lucas Hosseini
ee0283cb57
Simplify attributes handling.
2015-12-30 16:47:10 +01:00
Benjamin Fleischer
d7de53ce30
Consider evaluating association in serializer context
...
For discussion:
Consider evaluating association in serializer context
That way, associations are really just anything that
can be conditionally included. They no longer
have to actually be methods on the object or serializer.
e.g.
```diff
has_many :comments do
- last(1)
+ Comment.active.for_serialization(object).last(1)
end
```
2015-12-29 22:16:42 -06:00
Lucas Hosseini
fd06a8ad0d
Extract caching into its own module.
2015-12-28 02:53:49 +01:00
Benjamin Fleischer
b6a4ad1c26
Merge pull request #1383 from beauby/simplify-associations
...
Simplify reflections handling.
2015-12-22 10:37:28 -06:00
Benjamin Fleischer
fce856fc83
Merge pull request #1371 from bf4/documentation_updates
...
[DOCS] Refactor, update, create documentation
2015-12-20 22:30:44 -06:00
Benjamin Fleischer
30fd9d9eb7
Merge pull request #1353 from bf4/disable_serializer_lookup
...
Allow users to globally opt out of automatic serializer lookup
2015-12-20 20:04:16 -06:00
Lucas Hosseini
762f298c03
Simplify reflections handling.
2015-12-20 16:19:10 +01:00
Benjamin Fleischer
ce17a1b305
[DOCS] Refactor, update, create documentation [ci skip]
2015-12-14 14:38:29 -06:00
Benjamin Fleischer
bf8270b8b4
Document Serializer settings and private api [ci skip]
2015-12-10 15:08:22 -06:00
Benjamin Fleischer
386a567dfc
Evaluate association blocks as scopes on the association
2015-12-04 13:58:22 -06:00
Benjamin Fleischer
c4feccfd10
Refactor Association/Reflection block value reading
2015-12-03 10:53:43 -06:00
Benjamin Fleischer
cd736e0adf
Memoize attributes
2015-12-02 17:47:24 -06:00
Benjamin Fleischer
036604b149
Extract Serializer Attributes into its own file
2015-12-02 17:45:42 -06:00
Benjamin Fleischer
e2903643c5
Encapsulate serialized_associations; test inline associations
2015-12-02 17:20:22 -06:00
Lucas Hosseini
7cbef1b3b5
Add inline syntax for defining associations
...
Adapted from
https://github.com/rails-api/active_model_serializers/pull/1262
2015-12-02 17:20:22 -06:00
Benjamin Fleischer
28394340d8
Add config.serializer_lookup_enabled that defaults true
2015-11-30 00:20:58 -06:00
Trek Glowacki
170db3ba88
Allow users to globally opt out of automatic lookup
2015-11-30 00:15:02 -06:00
Benjamin Fleischer
a9ce4fb766
Move caching initialization to Railtie
...
Also
- Add reference to config from ActiveModelSerializers.config
- correctly call super in FragmentCacheTest#setup
- rename test rails app from Foo to ActiveModelSerializers::RailsApplication
2015-11-25 21:56:01 -06:00
Benjamin Fleischer
aa4384839d
Merge pull request #1322 from bf4/maurogeorge-patch-10
...
Instrumenting rendering of resources
2015-11-19 13:01:38 -06:00
Benjamin Fleischer
360ecc88fe
Clean up notification code with some meta-prog
2015-11-10 03:09:24 -06:00