Benjamin Fleischer
9909908962
Merge pull request #1384 from bf4/fix_ci_failures
...
Fix db state leaking across tests
2015-12-21 17:23:04 -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
Benjamin Fleischer
6aa5a4f7eb
Control db records created vs. tested against
2015-12-20 15:07:41 -06:00
Benjamin Fleischer
58937f4969
Clear out created db records after test
2015-12-20 15:02:16 -06:00
Benjamin Fleischer
dff607dc41
Merge pull request #1336 from johnhamelink/master
...
Grape formatter feature requested in #1258 - Rebased and Repushed (#1273 )
2015-12-17 20:31:38 -06:00
Benjamin Fleischer
ce17a1b305
[DOCS] Refactor, update, create documentation [ci skip]
2015-12-14 14:38:29 -06:00
Julian Paas
d85a17bb33
Grape formatter feature requested in #1258
...
- adds handling for when the returned resource is not serializable via ams
- fix for when resource is an Array
- Moves grape include to grape namespace. Changes Enumerable to Array because a plain hash is enumerable.
- Add integration test
- Refine scope of Grape version dependency
- Assert that the response is equal to a manually defined JSON string
- Add single module to include in Grape projects
- Create a Serializable Resource to test rails-api from Grape
- Update docs
- Fix discrepency between ActiveRecord 4.0 - 4.1 and 4.2
- Updated Changelog
- Remove parens from `render`, use `serializable` in all tests.
2015-12-10 10:06:40 +00:00
Benjamin Fleischer
386a567dfc
Evaluate association blocks as scopes on the association
2015-12-04 13:58:22 -06:00
Benjamin Fleischer
8804d758ef
Remove dynamically defined instance methods
2015-12-02 17:20:22 -06:00
Noah Silas
7bde7bf752
Handle conflicts between key names and serializer methods
...
As an example, all serializers implement `#object` as a reference to the
object being esrialized, but this was preventing adding a key to the
serialized representation with the `object` name.
Instead of having attributes directly map to methods on the serializer,
we introduce one layer of abstraction: the `_attributes_map`. This hash
maps the key names expected in the output to the names of the
implementing methods.
This simplifies some things (removing the need to maintain both
`_attributes` and `_attribute_keys`), but does add some complexity in
order to support overriding attributes by defining methods on the
serializer. It seems that with the addition of the inline-block format,
we may want to remove the usage of programatically defining methods on
the serializer for this kind of customization.
2015-12-02 17:20:22 -06:00
Benjamin Fleischer
e2903643c5
Encapsulate serialized_associations; test inline associations
2015-12-02 17:20:22 -06:00
Benjamin Fleischer
6020450fe4
Allow specifying attributes with a block
...
Adapted from https://github.com/rails-api/active_model_serializers/pull/1262
2015-12-02 17:20:22 -06:00
Randy Stauner
90fa377040
Match file paths with spaces in caller regexp
2015-12-02 06:17:34 -07:00
Benjamin Fleischer
28394340d8
Add config.serializer_lookup_enabled that defaults true
2015-11-30 00:20:58 -06:00
Benjamin Fleischer
8aaaa44ba3
Merge pull request #1324 from rails-api/get_tests_running_on_rails_master
...
Get tests passing on Rails 5
2015-11-25 22:49:10 -06:00
Benjamin Fleischer
6588dee22c
Rails5 requires x_action
2015-11-25 22:06:20 -06:00
Benjamin Fleischer
c56d49f26b
Test keyword args in requests for Rails 5; fallback for earlier versions
...
kwargs: params,session,flash,method,body
Fix Rails 5 DEPRECATION WARNING
2015-11-25 21:56:02 -06:00
Benjamin Fleischer
3b87cb3593
Patch ActionController::TestCase#assigns for Rails5
2015-11-25 21:56:01 -06:00
Benjamin Fleischer
d2a11678ef
ActiveModel::AttributeAssignment requires Model#respond_to_missing?
2015-11-25 21:56:01 -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
3dffd8a8b7
Add more warnings ignore directories
2015-11-25 21:49:23 -06:00
Peter Wagenet
39ef9bff10
Fix typo
2015-11-24 07:22:59 -08: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
733f5bca7e
Rename event from AMS to active_model_serializers
...
per NullVoxPopuli comment
2015-11-19 12:44:33 -06:00
Benjamin Fleischer
84c3b11491
Use null logger in test; keep track of original logger
2015-11-10 03:09:24 -06:00
Benjamin Fleischer
360ecc88fe
Clean up notification code with some meta-prog
2015-11-10 03:09:24 -06:00
Benjamin Fleischer
21bb306d38
Keep Logging in the ActiveModelSerializers namespace
2015-11-10 03:09:24 -06:00
Mauro George
51424963da
ActiveSupport::Notifications render.active_model_serializers
...
Squashed commits:
Add Logging
Generates logging when renders a serializer.
Tunning performance on notify_active_support
- Use yield over block.call
- Freeze the event name string
Organize the logger architeture
* Keep only the `ActiveModel::Serializer.logger` to follow the same public API we
have for example to config, like `ActiveModel::Serializer.config.adapter` and
remove the `ActiveModelSerializers.logger` API.
* Define the logger on the load of the AMS, following the Rails convention on
Railties [1], [2] and [3].
This way on non Rails apps we have a default logger and on Rails apps we will
use the `Rails.logger` the same way that Active Job do [4].
[1]: 2ad9afe4ff/activejob/lib/active_job/railtie.rb (L9-L11)
[2]: 2ad9afe4ff/activerecord/lib/active_record/railtie.rb (L75-L77)
[3]: 2ad9afe4ff/actionview/lib/action_view/railtie.rb (L19-L21)
[4]: 2ad9afe4ff/activejob/lib/active_job/logging.rb (L10-L11)
Performance tunning on LogSubscriber#render
Move the definition of locals to inside the `info` block this way the code is
executed only when the logger is called.
Remove not needed check on SerializableResource
Use SerializableResource on ActionController integration
On the ActionController was using a adapter, and since the instrumentation is
made on the SerializableResource we need to use the SerializableResource over
the adapter directly. Otherwise the logger is not called on a Rails app.
Use SerializableResource on the ActionController, since this is the main
interface to create and call a serializer.
Using always the SerializableResource we can keep the adapter code more easy to
mantain since no Adapter will need to call the instrumentation, only the
SerializableResource care about this.
Add docs about logging
Add a CHANGELOG entry
Keep the ActiveModelSerializers.logger
Better wording on Logging docs
[ci skip]
Add doc about instrumentation
[ci skip]
Use ActiveModel::Callbacks on the SerializableResource
2015-11-10 03:09:24 -06:00
Benjamin Fleischer
14a06d96c4
Only capture stderr on Ruby 2.1 on CI
...
Always show warnings in tests
2015-11-09 00:35:02 -06:00
Benjamin Fleischer
e5a109865c
Test ArraySerializer less rigorously on Minitest 4
2015-11-08 23:12:56 -06:00
tchak
31172b1be5
rename context to serialization_context
2015-11-07 20:32:27 +01:00
Paul Chobert
6407dbeadd
Add test and bugfix to include an array of string
2015-11-06 17:23:25 +01:00
Lucas Hosseini
3804dcc238
Add support for resource-level JSON API links.
2015-11-03 23:50:16 +01:00
L. Preston Sego III
17be650538
Revert "rename context to serialization_context and add url helpers"
2015-10-29 08:16:47 -04:00
L. Preston Sego III
a063cbea21
Merge pull request #1289 from tchak/serialization_context
...
rename context to serialization_context and add url helpers
2015-10-29 07:56:47 -04:00
L. Preston Sego III
48b041ecae
Merge pull request #1294 from beauby/fix-serializer-lookup-non-ams
...
Only use subclasses of ActiveModel::Serializer during lookup.
2015-10-25 23:01:00 -04:00
Lucas Hosseini
13ef8fed1b
Fix fields option to restrict relationships as well.
2015-10-24 21:28:13 +02:00
Lucas Hosseini
1a42345d84
Only use subclasses of ActiveModel::Serializer during lookup.
2015-10-23 17:17:03 +02:00
tchak
d08ee5994f
rename context to serialization_context and add url helpers
2015-10-22 22:28:54 +02:00
Benjamin Fleischer
2c8b9b796d
Rename ArraySerializer to CollectionSerializer for clarity
2015-10-21 16:53:26 -05:00
Benjamin Fleischer
737784c9b7
Merge pull request #1272 from bf4/add_public_poro_base
...
Add PORO serializable base class: ActiveModelSerializers::Model
2015-10-20 12:50:05 -05:00
L. Preston Sego III
b2cd7bb51a
Merge pull request #1271 from bf4/fix_digest_failure
...
Handle no serializer source file to digest.
2015-10-16 09:23:56 -04:00
L. Preston Sego III
240387bc45
Merge pull request #1242 from beauby/improve-ministest
...
Better reporter for tests.
2015-10-15 16:39:53 -04:00
Benjamin Fleischer
124faaa829
Add PORO serializable base class: ActiveModelSerializers::Model
2015-10-14 21:33:02 -05:00
Benjamin Fleischer
8529ea43c9
Handle no serializer source file to digest.
...
output warning
Closes #1176
2015-10-14 20:56:29 -05:00
João Moura
da7e6dc795
Merge pull request #1247 from beauby/jsonapi-toplevel-links
...
Add support for toplevel JSON API links.
2015-10-10 17:52:08 -03:00
L. Preston Sego III
6018ef16c4
Merge pull request #1225 from beauby/nested-serializer-lookup
...
Add support for nested serializers
2015-10-09 10:12:08 -04:00
Benjamin Fleischer
49eb531539
Merge pull request #1239 from beauby/fix-duplicate-jsonapi
...
Fix duplicate resources inside included in compound document.
2015-10-08 14:19:02 -05:00
Lucas Hosseini
9147469842
Extend serializer lookup to the parent serializer.
2015-10-08 18:23:54 +02:00
Lucas Hosseini
eccb359cb9
Fix unnecessary nested serializers.
2015-10-08 18:13:58 +02:00
L. Preston Sego III
d5e6e3148a
Merge pull request #1254 from bf4/remove_useless_access_modifier
...
Remove unnecessarily silenced warnings
2015-10-07 07:22:15 -04:00
Benjamin Fleischer
659e31b519
Change assert to assert_equal
2015-10-07 05:59:43 -05:00
Benjamin Fleischer
dc44b136aa
Remove unnecessarily silenced warnings
2015-10-07 05:54:57 -05:00
Rodrigo Ra
5706e7d7fe
serializer inherits cache configuration
2015-10-07 00:34:21 -03:00
Lucas Hosseini
54303b6290
Add support for toplevel JSON API links.
2015-10-06 20:01:46 +02:00
Lucas Hosseini
f4bb4c81b0
Fix duplicate resources between data and included.
2015-10-06 17:25:27 +02:00
Lucas Hosseini
29c3448922
Better reporter for tests.
2015-10-06 02:15:29 +02:00
Lucas Hosseini
503bfe9598
Move meta/meta_key handling inside adapter.
2015-10-05 19:06:50 +02:00
Lucas Hosseini
658810e6a0
Extract attributes filtering from serializer into adapter.
2015-10-05 08:21:26 +02:00
Lucas Hosseini
34d65716cb
Merge pull request #1214 from NullVoxPopuli/issue/1211-failing-test
...
Fix #1211 , include_tree is null when using the key: options
2015-10-02 15:29:04 +02:00
Liam Bowen
f8323fc9e5
Fixes #1211 - retrieve the key from the reflection options when building associations
2015-10-02 08:52:21 -04:00
Benjamin Fleischer
a2bfe190e3
Merge pull request #1050 from bf4/json_api_member
...
Add top-level jsonapi member to JSON API adapter
2015-10-01 23:03:11 -05:00
Ivan Yurov
2dd569ae51
Add Serializer 'type' directive to control type field, for use by the JsonApi adapter
2015-10-01 22:48:57 -04:00
Benjamin Fleischer
9d7da8afc4
Add support for top level jsonapi member.
2015-10-01 21:22:49 -05:00
Lucas Hosseini
359f290ddc
Add failing test.
2015-09-23 18:59:18 +02:00
Benjamin Fleischer
e9a15a3b80
Merge pull request #1187 from bf4/remove_dead_code
...
Remove dead code
2015-09-21 10:45:14 -05:00
Lucas Hosseini
606e2ae337
Merge pull request #1127 from NullVoxPopuli/support-nested-associations-for-json-adapter
...
Support nested associations for Json and Attributes adapters + Refactor Attributes adapter
2015-09-21 17:20:29 +02:00
Benjamin Fleischer
839d1ab21c
Remove dead code
2015-09-21 09:41:54 -05:00
L. Preston Sego III
a74ea189cd
Refactors of the Attribute adapter. Adds support for nested associations specified from the include key in the controller. Adds some tests and some method documentation
2015-09-21 10:35:47 -04:00
Benjamin Fleischer
bac43af0e6
Merge pull request #1175 from bf4/quiet_success_messages
...
Disable coverage/warnings output when passing in dev
2015-09-21 09:31:49 -05:00
L. Preston Sego III
8f2dd66710
Merge pull request #1183 from rails-api/block_style
...
Update Rubocop todo
2015-09-21 01:25:50 -05:00
Benjamin Fleischer
076cf64ff3
Disable coverage/warnings output when passing in dev
2015-09-21 00:39:56 -05:00
Lucas Hosseini
88785ea21e
Add failing test.
2015-09-21 07:11:23 +02:00
Benjamin Fleischer
ca6b193fcb
Enforce Rails-style (line-count-based) block style
2015-09-21 00:00:53 -05:00
Lucas Hosseini
ac06013aeb
Add support for wildcard includes + improve perfs on JsonApi includes.
2015-09-21 05:58:00 +02:00
Benjamin Fleischer
19de5f7722
Introduce Adapter::Base
...
Breaking change:
- Adapters now inherit Adapter::Base
- 'Adapter' is now a module, no longer a class
Why?
- using a class as a namespace that you also inherit from is complicated and circular at time i.e.
buggy (see https://github.com/rails-api/active_model_serializers/pull/1177 )
- The class methods on Adapter aren't necessarily related to the instance methods, they're more
Adapter functions
- named `Base` because it's a Rails-ism
- It helps to isolate and highlight what the Adapter interface actually is
2015-09-20 12:26:04 -05:00
Benjamin Fleischer
2e7222323c
env CAPTURE_STDERR=false lets devs see hard failures
2015-09-18 15:20:55 -05:00
Benjamin Fleischer
ad2ca3b45c
Remove Adapter autoloads in favor of require
...
Adapters must be eager loaded to ensure they are defined
before they are used as namespacing.
cf6a074a1c (diff-41f2b3509d33e1c65bb70ee0ec7a2eea)
2015-09-18 12:44:53 -05:00
Benjamin Fleischer
c6f8d0f5f2
Rename FlattenJson to Attributes (allow plural adapter names)
2015-09-18 10:17:02 -05:00
Benjamin Fleischer
eb1264ad99
Better serializer registration, get more than just the first module
...
But is potentially breaking anyone on rc3, but the fix is just
to manually register the adapter with the rc3-style name
2015-09-17 23:33:04 -05:00
Benjamin Fleischer
9d65f0adc5
Distinguish options ivar from local; Extract latent Adapter::CachedSerializer
2015-09-17 10:45:09 -05:00
Benjamin Fleischer
3f0794bd39
Merge pull request #1168 from bf4/fix_appveyor
...
Fix appveyor failure cache not being expired
2015-09-17 10:05:40 -05:00
Benjamin Fleischer
c43e8e2a32
Fix or skip appveyor failure on cache expiration
2015-09-17 09:30:29 -05:00
Benjamin Fleischer
26277ea1f9
Remove duplicate test helper
2015-09-16 08:54:33 -05:00
L. Preston Sego III
a34cb998c7
rubocop-fixes
2015-09-15 14:58:04 -04:00
L. Preston Sego III
1bff6173d1
Merge pull request #1089 from bf4/add_logger
...
Add ActiveModelSerializers.logger with default null device
2015-09-15 14:51:29 -04:00
L. Preston Sego III
a453de112b
Merge pull request #1109 from bf4/fix_minitest_after_run
...
Make better use of Minitest's lifecycle
2015-09-15 14:18:07 -04:00
Lucas Hosseini
7e2f3d122b
Merge pull request #1110 from beauby/add-ar-models-tests
...
Add lint tests for AR models
2015-09-14 02:05:54 +02:00
Lucas Hosseini
ce7a839f3d
Extended format for JSONAPI include option.
2015-09-13 22:45:47 +02:00
Benjamin Fleischer
363345b8dd
Rename Adapter.get to Adapter.lookup
...
Per https://github.com/rails-api/active_model_serializers/pull/1017#discussion_r39003855
comment by sandstrom in discussion of the inherited hook
> I'm thinking that it would be better to register adapters manually, without using the hook, i.e.
> have people call ActiveModel::Serializer::Adapter.register directly (perhaps in an initializer).
> Possibly, some inspiration can be taken from how ActiveJob adapters are wired[1].
> [1] a11571cec3/activejob/lib/active_job/queue_adapter.rb (L52-L56)
2015-09-09 08:55:20 -05:00
Benjamin Fleischer
af99c0d9e6
Ensure inheritance hooks run
...
I was seeing transient failures where adapters may not be registered.
e.g. https://travis-ci.org/rails-api/active_model_serializers/builds/77735382
Since we're using the Adapter, JsonApi, and Json classes
as namespaces, some of the conventions we use for modules don't apply.
Basically, we don't want to define the class anywhere besides itself.
Otherwise, the inherited hooks may not run, and some adapters may not
be registered.
For example:
If we have a class Api `class Api; end`
And Api is also used as a namespace for `Api::Product`
And the classes are defined in different files.
In one file:
```ruby
class Api
autoload :Product
def self.inherited(subclass)
puts
p [:inherited, subclass.name]
puts
end
end
```
And in another:
```ruby
class Api
class Product < Api
def sell_sell_sell!
# TODO: sell
end
end
end
```
If we load the Api class file first, the inherited hook will be defined on the class
so that when we load the Api::Product class, we'll see the output:
```plain
[ :inherited, Api::Product]
```
However, if we load the Api::Product class first, since it defines the `Api` class
and then inherited from it, the Api file was never loaded, the hook never defined,
and thus never run.
By defining the class as `class Api::Product < Api` We ensure the the Api class
MUST be defined, and thus, the hook will be defined and run and so sunshine and unicorns.
Appendix:
The below would work, but triggers a circular reference warning.
It's also not recommended to mix require with autoload.
```ruby
require 'api'
class Api
class Product < Api
def sell_sell_sell!
# TODO: sell
end
end
end
```
This failure scenario was introduced by removing the circular reference warnings in
https://github.com/rails-api/active_model_serializers/pull/1067
Style note:
To make diffs on the adapters smalleer and easier to read, I've maintained the same
identention that was in the original file. I've decided to prefer ease of reading
the diff over style, esp. since we may later return to the preferred class declaration style.
with '#' will be ignored, and an empty message aborts the commit.
2015-09-09 08:55:20 -05:00
Benjamin Fleischer
d9e76c29d5
Make Adapters registerable so they are not namespace-constrained
...
Changes:
- Introduce Adapter::get for use by Serializer.adapter
- Move Adapter-finding logic from Adapter::adapter_class into Adapter::get
Introduced interfaces:
- non-inherited methods
```ruby
ActiveModel::Serializer::Adapter.adapter_map # a Hash<adapter_name, adapter_class>
ActiveModel::Serializer::Adapter.adapters # an Array<adapter_name>
ActiveModel::Serializer::Adapter.register(name, klass) # adds an adapter to the adapter_map
ActiveModel::Serializer::Adapter.get(name_or_klass) # raises Argument error when adapter not found
```
- Automatically register adapters when subclassing
```ruby
def self.inherited(subclass)
ActiveModel::Serializer::Adapter.register(subclass.to_s.demodulize, subclass)
end
```
- Preserves subclass method `::adapter_class(adapter)`
```ruby
def self.adapter_class(adapter)
ActiveModel::Serializer::Adapter.get(adapter)
end
```
- Serializer.adapter now uses `Adapter.get(config.adapter)` rather than have duplicate logic
2015-09-08 22:59:36 -05:00
Lucas Hosseini
ec6260870d
Add lint tests for AR models.
2015-09-07 18:34:42 +02:00
Bruno Bacarini
8634503849
Remove url options
...
Removing url options because It does not works at all.
Thus, there are others PR at the moment to include url(links) as well.
2015-09-07 12:13:19 -03:00
Lucas Hosseini
890003b305
Minor style improvements.
2015-09-07 09:06:17 +02:00
Lucas Hosseini
ebb05959d3
Merge remote-tracking branch 'upstream/master' into improve-tests
2015-09-07 09:03:17 +02:00
João Moura
6799453f09
Merge pull request #1069 from bf4/coverage
...
Add test coverage; account for no artifacts on CI
2015-09-06 17:58:54 -03:00
Lucas Hosseini
070a2e63bd
Merge remote-tracking branch 'upstream/master' into fix-jsonapi-ri
2015-09-06 17:21:43 +02:00
Benjamin Fleischer
94469be1ca
Add test coverage; account for no artifacts on CI
...
Drop coverage a bit for JRuby and Rubinius because they
don't generate the same Coverage as CRuby
2015-09-06 09:19:07 -05:00
Benjamin Fleischer
b18671fd03
Make better use of Minitest's lifecycle
...
http://blog.arkency.com/2013/06/are-we-abusing-at-exit/
2015-09-06 07:34:42 -05:00
Benjamin Fleischer
8e8f6aba7e
Remove space in {}
2015-09-03 20:55:40 -05:00
Benjamin Fleischer
228cc1c92a
Rubocop: Consistent spacing
2015-09-03 20:51:40 -05:00
Benjamin Fleischer
bdfe13c527
Style/StringLiterals single quote all the things
2015-09-03 20:50:45 -05:00
Benjamin Fleischer
09c97de90d
Add Style enforcer (via Rubocop)
...
It will fail the build, but as it is currently,
most of the cops are 'todos'. Great for new contributors.. :)
2015-09-03 20:50:45 -05:00
João Moura
6784866a2d
Merge pull request #1079 from bf4/all_serializer_have_object
...
Add ArraySerializer#object like Serializer
2015-09-03 01:43:14 -03:00
Lucas Hosseini
b6b8dff8c9
Merge remote-tracking branch 'upstream/master' into improve-tests
2015-09-01 21:25:28 +02:00
João Moura
e0b74d8731
Merge pull request #1096 from beauby/fix-attribute
...
Fix definition of serializer attributes with multiple calls to `attri…
2015-09-01 09:42:59 -03:00
João Moura
8d3a89e106
Merge pull request #1105 from beauby/add-activerecord-fixtures
...
Add ActiveRecord-backed fixtures.
2015-08-31 02:37:57 -03:00
Benjamin Fleischer
005f71e2c2
Add ActiveModelSerializers.logger with default null device
2015-08-30 23:26:31 -05:00
Lucas Hosseini
83f11acd66
Add Gemfile dependencies to ActiveRecord and sqlite3.
2015-08-31 06:19:16 +02:00
Lucas Hosseini
d0d00d02a0
Add ActiveRecord-backed fixtures.
2015-08-31 05:11:32 +02:00
Lucas Hosseini
8482abfac7
Move id and json_api_type methods from Serializer to JsonApi.
2015-08-31 02:32:38 +02:00
Lucas Hosseini
c5446d759f
Remove traces of embed option.
2015-08-31 01:26:22 +02:00
Lucas Hosseini
995bbcc18d
Fix definition of serializer attributes with multiple calls to attribute instead of one single call to attributes.
2015-08-28 21:06:10 +02:00
Lucas Hosseini
4bba16bf4e
Factor with_adapter + force cache clear before each test.
2015-08-28 17:00:24 +02:00
João Moura
64168cbecd
Merge pull request #1081 from beauby/jsonapi-singular-plural-config
...
Add configuration option to set resource type to singular/plural
2015-08-28 07:47:55 -03:00
Benjamin Fleischer
d315151e8a
Fix warnings
...
JRuby-specific: fix 'warning: (...) interpreted as grouped expression'
2015-08-26 09:22:02 -05:00
Benjamin Fleischer
9aad8b4d29
Cleanup CaptureWarnings after_run
2015-08-26 09:19:36 -05:00
Benjamin Fleischer
a8e9bb1c14
Remove uniq on warnings that confused output
2015-08-26 09:19:36 -05:00
Benjamin Fleischer
530a1bdfd7
Compartmentalize test helper support
2015-08-26 09:19:36 -05:00
João Moura
af280abbb7
Merge pull request #1066 from rails-api/appveyor
...
Adding appveyor to the project
2015-08-26 04:46:16 -03:00
Lucas Hosseini
91235ba7bc
Add configuration option to set resource type to singular/plural with jsonapi.
2015-08-24 22:55:22 +02:00
Benjamin Fleischer
dc4ee94fea
Add ArraySerializer#object like Serializer
2015-08-24 13:51:46 -05:00
João Moura
87c47f8fdc
Merge pull request #1041 from bacarini/master
...
Adding pagination links
2015-08-22 13:38:32 -03:00
Eric Guo
30463f88fa
Make testing suite running and pass in Windows
...
thanks @bf4 give many help and suggestion, original PR https://github.com/rails-api/active_model_serializers/pull/1014
2015-08-21 21:07:52 +08:00
Bruno Bacarini
d50262edbe
test pagination links the way the controller does
2015-08-20 11:32:03 -03:00
Bruno Bacarini
01eab3bdb4
send whole request context to model serializer
2015-08-19 10:48:48 -03:00
Bruno Bacarini
5031eb9f96
add test to prev and first with additional params
2015-08-18 19:04:04 -03:00
Bruno Bacarini
2c2f948fa0
Add pagination links automatically
...
Pagination links will be included in your response automatically as long
as the resource is paginated using Kaminari or WillPaginate
and if you are using a JSON-API adapter. The others adapters does not have this feature.
2015-08-18 19:04:04 -03:00
Bruno Bacarini
a41d90cce4
add self to pagination links
2015-08-18 19:04:04 -03:00
Bruno Bacarini
e0d050d2af
remove resource and options attr_reader from array_serialize
2015-08-18 19:04:03 -03:00
Bruno Bacarini
7be25fef14
include query_parameters on pagination links as well
2015-08-18 19:04:03 -03:00
Bruno Bacarini
e62a7d6f34
return complete URIs on pagination links
2015-08-18 19:04:03 -03:00
Bruno Bacarini
331218d1c3
add test to class of pagination links
2015-08-18 19:04:03 -03:00
Bruno Bacarini
e040d6fcce
add action test to pagination links
2015-08-18 19:04:02 -03:00
Bruno Bacarini
1fe8b06986
exchange pagination class to inside json_api scope
2015-08-18 19:04:02 -03:00
Benjamin Fleischer
215fb85c7f
Test caller line parsing and digesting
2015-08-18 17:32:29 -04:00
Benjamin Fleischer
dca286b0ec
Lead by example: lint PORO model
2015-08-18 12:59:12 -04:00
Aaron Lerch
35c8f0d835
Update fragment cache to support namespaced objects
2015-08-17 17:12:30 -04:00
Mikhail Topolskiy
e8e4bdefd2
Use underscored json_root
2015-08-13 20:31:48 +03:00
Josh Lane
033ce8e88d
allow for a type attribute
...
* "namespace" json_api specific type method
2015-08-11 08:33:05 -07:00
Josh Lane
f6e3d4e1f9
allow id attribute to be overriden
2015-08-04 09:22:05 -07:00
João Moura
c703d0f35c
Merge pull request #985 from bolshakov/feature/each_association
...
Associations implementation refactoring
2015-07-31 10:57:03 -03:00
João M. D. Moura
88eabdf6ac
fixing tests by using a Profile intance to avoid unrelated warning
2015-07-31 03:28:50 -03:00
João Moura
b78126565c
Merge pull request #954 from bf4/encapsulate_serialization
...
Encapsulate serialization in ActiveModel::SerializableResource
2015-07-31 03:09:58 -03:00
João Moura
7bc16666fe
Merge pull request #972 from bf4/capture_app_warnings
...
Capture app warnings on test run
2015-07-30 22:24:08 -03:00
Артём Большаков
2952a332e0
Associations refactoring
...
* Move all associations related code from Serializer class to Associations module
* Introduce Reflection class hierarchy
* Introduce Association class
* Rid off Serializer#each_association
* Introduce Serializer#associations enumerator
2015-07-30 11:20:29 +03:00
Benjamin Fleischer
df140293d3
Remove unused controller rescue_with_handler
...
Per
https://github.com/rails-api/active_model_serializers/pull/954#discussion_r32589882
Ref 917, 918
2015-07-23 11:06:11 -05:00
Benjamin Fleischer
a66df3009a
Encapsulate serialization in ActiveModel::SerializableResource
...
Usage: ActiveModel::SerializableResource.serialize(resource, options)
2015-07-23 11:05:23 -05:00
João Moura
9817a5b595
updating tests
2015-07-23 02:11:34 -04:00
João Moura
6266b6a002
Merge pull request #1006 from bf4/inflector-testing
...
Fix adapter inflection bug for api -> API
2015-07-20 23:20:00 -04:00
vyrak bunleang
1b09d0ec42
array serializer uses root option for json_key if available
2015-07-16 15:34:19 -06:00
vyrak bunleang
1d31096600
include old implicit serialization custom root tests with failing empty array test
2015-07-16 15:32:09 -06:00
Marek Pietrucha
e5ccb8e4dd
root option is working ( fixed #986 )
2015-07-16 15:32:09 -06:00
Jiajia Wang
91ffec41af
Add test for ArraySerializer json_key method
...
test json key when resource is empty
2015-07-16 11:11:14 +10:00
Benjamin Fleischer
e7174a7820
Capture and print app warnings on test run
...
Configure not to fail the test, for now
2015-07-14 01:05:26 -05:00
Rodrigo Ra
851d121ea8
fix transient test failures
2015-07-13 22:44:04 -03:00
João Moura
775737619a
Merge pull request #996 from bf4/serializer_lint
...
Add linter for serializable resource
2015-07-13 19:37:39 -04:00
Rob McFadzean
506739d4fb
Added a (failing) test for when inflecting API
2015-07-10 11:23:55 +09:30
Benjamin Fleischer
28174e297d
Add linter for serializable resource
2015-07-09 11:20:19 -05:00
João Moura
7fb94234a8
adding json-api meta test help
2015-07-08 10:15:14 -03:00
Rodrigo Ra
df63b59512
Add key option to serializer associations
2015-07-05 19:47:58 -03:00
João Moura
ac1991fd6b
Merge pull request #982 from bf4/typo
...
Fix typo
2015-07-02 19:06:32 -03:00
Benjamin Fleischer
58a237ead1
Fix typo
2015-07-02 16:35:27 -05:00
Benjamin Fleischer
1bf2825909
Remove unused PORO#to_param
2015-07-02 16:34:10 -05:00
João Moura
952d8adcdc
Merge pull request #978 from regonn/fix-generators-template
...
fix generators template bug
2015-07-02 00:31:55 -03:00
regonn
59a177e8b5
add serializer template test
2015-07-01 13:42:16 +09:00
Hugo Almeida
f25071ca70
Fixes virtual value not being used
2015-06-29 10:48:12 +09:00
Rodrigo Ra
7412c8d1c8
Fix transient tests failures
2015-06-26 09:33:53 -03:00
Benjamin Fleischer
17d560eae4
Account for different handling of symbol keys in Rails 4.0
...
Comparing as a JSON string vs. as the Hash that is convert to JSON
works around the different Hash representations.
This likely has to do with the introduction of
config.action_dispatch.perform_deep_munge in Rails 4.1
See Rails issue 13420
1) Failure:
ActiveModel::Serializer::Adapter::Json::HasManyTestTest#test_has_many_with_no_serializer
[active_model_serializers/test/adapter/json/has_many_test.rb:36]:
--- expected
+++ actual
@@ -1 +1 @@
-{:id=>42, :tags=>[{"attributes"=>{"id"=>1, "name"=>"#hash_tag"}}]}
+{:id=>42, :tags=>[{"attributes"=>{:id=>1, :name=>"#hash_tag"}}]}
2) Failure:
ActiveModel::Serializer::AssociationsTest#test_has_many_with_no_serializer
[active_model_serializers/test/serializers/associations_test.rb:74]:
--- expected
+++ actual
@@ -1 +1 @@
-[{"attributes"=>{"name"=>"#hashtagged"}}]
+[{"attributes"=>{:name=>"#hashtagged"}}]
2015-06-26 02:16:35 -03:00
João Moura
741c4a4b51
updating tests to work with new virtual_value implementation
2015-06-26 02:16:35 -03:00
Benjamin Fleischer
cf77786da2
Fix #955
2015-06-26 02:16:34 -03:00
Justin Aiken
3710c32cee
Add some failing tests around has_many assocs...
...
..where no serializer is defined for the thing that is has_many'd
2015-06-26 02:16:34 -03:00
João Moura
d589268f95
adding new tests to cover array and object rendering
2015-06-26 02:15:42 -03:00
Aaron Lerch
6892ca39c9
Default the generated cache key to use custom #strftime instead of raw #to_s to achieve more accurate precision
2015-06-25 23:40:18 -04:00
Benjamin Fleischer
81935c8114
Restore has_one to generator
...
per #822 since it was readded in #725
2015-06-25 14:00:27 -05:00
João Moura
f67fd976ec
Removing/Updating tests based on new FlattenJson adapter
2015-06-18 19:18:11 -03:00
João Moura
65e0d79195
pluralising root key when using arraySerializer
2015-06-15 15:59:01 -03:00
João Moura
329691276a
disabling custom root option
2015-06-15 15:58:39 -03:00
João Moura
d061b2e9f4
enabling flatten json as default adapter
2015-06-15 13:49:24 -03:00
João Moura
1ea5608e78
updating tests to match new adapters structure
2015-06-15 13:39:36 -03:00
João Moura
37114e9d5b
removing unnecessary root parameter on fragment cache
2015-06-13 15:48:33 -03:00
Lachlan Sylvester
97e82c3eb7
use model name to determine the type
2015-06-13 19:45:46 +10:00
João Moura
de23501995
Merge pull request #949 from edwardloveall/el-870-fix
...
Don't pass serializer option to associated serializers
2015-06-13 03:01:25 -03:00
João Moura
6251b90d25
Merge pull request #902 from cristianbica/serializer_file_digest
...
Added serializer file digest to the cache_key
2015-06-12 18:56:43 -03:00
Benjamin Fleischer
14439aada4
Use model that doesn't fail with race condition
...
For some reason, the post would sometimes be serialized as
"{\"id\":\"1\",
+ \"type\":\"posts\", \"attributes\":{\"title\":\"New Post\",\"body\":\"Body\"},
\"comments\":[{\"id\":1,\"body\":\"ZOMG A COMMENT\"}],
\"blog\":{\"id\":999,\"name\":\"Custom blog\"},
\"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"
instead of:
"{\"id\":1,
- \"title\":\"New Post\",\"body\":\"Body\",
\"comments\":[{\"id\":1,\"body\":\"ZOMG A COMMENT\"}],
\"blog\":{\"id\":999,\"name\":\"Custom blog\"},\
"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"
To reproduce prior to this PR:
SEED=55284 rake
1) Failure:
ActionController::Serialization::ExplicitSerializerTest#test_render_using_explicit_each_serializer
[active_model_serializers/test/action_controller/explicit_serializer_test.rb:139]:
--- expected
+++ actual
@@ -1 +1 @@
-"{\"id\":1,\"title\":\"New
Post\",\"body\":\"Body\",\"comments\":[{\"id\":1,\"body\":\"ZOMG A
COMMENT\"}],\"blog\":{\"id\":999,\"name\":\"Custom
blog\"},\"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"
+"{\"id\":\"1\",\"type\":\"posts\",\"attributes\":{\"title\":\"New
Post\",\"body\":\"Body\"},\"comments\":[{\"id\":1,\"body\":\"ZOMG A
COMMENT\"}],\"blog\":{\"id\":999,\"name\":\"Custom
blog\"},\"author\":{\"id\":1,\"name\":\"Joao Moura.\"}}"
137 runs, 211 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib:test"
-r./test/test_helper.rb
"/$HOME/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb"
"test/action_controller/adapter_selector_test.rb"
"test/action_controller/explicit_serializer_test.rb"
"test/action_controller/json_api_linked_test.rb"
"test/action_controller/rescue_from_test.rb"
"test/action_controller/serialization_scope_name_test.rb"
"test/action_controller/serialization_test.rb"
"test/adapter/fragment_cache_test.rb"
"test/adapter/json/belongs_to_test.rb"
"test/adapter/json/collection_test.rb"
"test/adapter/json/has_many_test.rb"
"test/adapter/json_api/belongs_to_test.rb"
"test/adapter/json_api/collection_test.rb"
"test/adapter/json_api/has_many_embed_ids_test.rb"
"test/adapter/json_api/has_many_explicit_serializer_test.rb"
"test/adapter/json_api/has_many_test.rb"
"test/adapter/json_api/has_one_test.rb"
"test/adapter/json_api/linked_test.rb" "test/adapter/json_test.rb"
"test/adapter/null_test.rb" "test/adapter_test.rb"
"test/array_serializer_test.rb" "test/serializers/adapter_for_test.rb"
"test/serializers/associations_test.rb"
"test/serializers/attribute_test.rb"
"test/serializers/attributes_test.rb" "test/serializers/cache_test.rb"
"test/serializers/configuration_test.rb"
"test/serializers/fieldset_test.rb"
"test/serializers/generators_test.rb" "test/serializers/meta_test.rb"
"test/serializers/options_test.rb"
"test/serializers/serializer_for_test.rb"
"test/serializers/urls_test.rb" ]
/$HOME/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in
`eval'
/$HOME/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in
`<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
2015-06-12 11:27:28 -05:00
Benjamin Fleischer
a5554e0d9f
Use a different controller in different tests
...
A number of test were defining and using the same controller
MyController = Class.new(ActionController::Base)
which was causing some state to leak across tests.
2015-06-12 11:27:20 -05:00
Santiago Pastorino
460150fef2
Fix No such file or directory tmp/cache issue in tests
2015-06-10 21:23:23 -03:00
Santiago Pastorino
4752e6723a
Make resource generator invoke serializer generator
2015-06-10 20:45:33 -03:00
Santiago Pastorino
e117615465
This should be MAJOR >= 4
2015-06-10 20:26:37 -03:00
Santiago Pastorino
3fb55db1cd
Load generators on test_helper and avoid repetead code
2015-06-10 20:26:37 -03:00
Santiago Pastorino
cbc7f114c0
Move generators test to it's own directory
2015-06-10 20:26:24 -03:00
Edward Loveall
0f0ef2baf5
Don't pass serializer option to associated serializers
...
Fixes #870
Commit af81a40 introduced passing a serializer's 'options'
along to its associated model serializers.
Thus, an explicit 'each_serializer' passed to render for a
singular resource would be passed on as the implicit 'serializer'
for its associations.
With @bf4
2015-06-10 18:20:34 -04:00
João Moura
7b0a85fdda
Merge pull request #936 from insphire/fix-meta-with-custom-root
...
Include meta when using json adapter with custom root
2015-06-08 19:55:03 -03:00
Thiago Fernandes Massa
5fac4d8f33
Update poro.rb
2015-06-05 10:50:35 +02:00
Chris Branson
d34bba07b9
Ensure the adapters honor a custom root option and include meta when required
2015-06-04 17:33:41 +01:00
João Moura
a40df8fd3d
reverting PR #909 and adding json api usage advise on readme
2015-05-27 18:35:00 -03:00
Benedikt Deicke
4f576a1463
Adjusts JsonApi adapter to serialize relationships in a nested relationships hash
2015-05-21 16:35:35 +02:00
Benedikt Deicke
ca41901fb8
Adjusts JsonApi adapter to serialize attributes in a nested attributes hash
2015-05-21 16:23:01 +02:00