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
João Moura
5f05944826
Merge pull request #918 from aceofsales/rescue_from
...
Adding rescue_with_handler to clear state
2015-05-20 23:39:45 -03:00
Guillermo Iguaran
f7fb4dbb98
Merge pull request #909 from joaomdmoura/json-api-default
...
Defining Json-API Adapter as Default
2015-05-20 20:50:19 -05:00
Ryan Schlesinger
a5db2c52c5
Clearer exception description
2015-05-20 09:19:32 -07:00
Ryan Schlesinger
9355416ad0
Add rescue_from handler to clear state
...
Fixes #917
2015-05-19 17:23:29 -07:00
groyoh
5393e5d235
Prevent possible duplicated attributes
...
Calling ActiveModel::Serializer.attributes or ActiveModel::Serializer.attribute
methods multiple times won't create duplicated attributes anymore.
2015-05-18 22:42:10 +02:00
João Moura
d981ee5106
Merge pull request #880 from groyoh/serializer-inheritance
...
Inabling subclasses serializers to inherit attributes
2015-05-18 11:34:10 -03:00
groyoh
a794a06fa5
Fixed #911
2015-05-17 22:47:44 +02:00
João Moura
9b502a4ae0
changing tests name to support new default adapter
2015-05-11 16:23:38 -03:00
João Moura
2c9c36e21f
adding json_api as default adapter
2015-05-10 03:58:18 -03:00
João Moura
46ae776175
Merge pull request #897 from imanel/patch-1
...
Allow to define custom serializer for given class
2015-05-10 03:28:14 -03:00
Cristian Bica
7a62d31777
Added serializer file digest to the cache_key
...
Fixes #901
2015-05-06 08:37:18 +03:00
João Moura
ece43f344a
Merge pull request #892 from groyoh/fix-json-nil-association
...
Fixed a bug that appeared when json adapter serialize a nil association
2015-05-05 11:04:26 -03:00
Bernard Potocki
c91b649504
Allow to define custom serializer for given class by defining #serializer_class method in serialized object's class. Resolves #515 .
2015-05-03 17:47:52 +02:00
Attila Domokos
bd06647b31
Adding a test to cover 'meta' and 'meta_key' attr_readers
2015-04-30 22:17:19 -05:00
groyoh
5dcdfaaef3
Fixed a bug that appeared when json adapter serialize a nil association
2015-04-28 22:20:21 +02:00
João Moura
fc6276cab8
Merge pull request #888 from groyoh/fix-action-controller-test-name
...
Changed duplicated test name in action controller test
2015-04-28 12:09:02 -03:00
Justin Aiken
cf1c57d2a9
Remove unused method
2015-04-27 16:53:36 -06:00
groyoh
1ef2badb32
Changed duplicated test name in action controller test
2015-04-27 21:22:28 +02:00
João Moura
49e41cb83c
adding tests order config
2015-04-27 15:45:49 -03:00
Yohan Robert
02ffff599f
Serializers now inherit attributes
2015-04-23 13:25:36 +02:00
Alexandre de Oliveira
168c36fc7d
Merge pull request #810 from joaomdmoura/fragment-cache
...
Adding Fragment Cache to AMS
2015-04-21 17:57:55 -03:00
João Moura
792fb8a905
Adding Fragment Cache to AMS
...
It's an upgrade based on the new Cache implementation #693 .
It allows to use the Rails conventions to cache
specific attributes or associations.
It's based on the Cache Composition implementation.
2015-04-05 18:19:57 -03:00
Yohan Robert
6a0564a241
Fixed a bug that appears when a nil association is included
2015-04-03 12:50:05 +02:00
Mateo Murphy
5e560ddbef
Fix skipped test and add test for duplicate links
2015-03-24 19:46:30 -04:00
Mateo Murphy
9480b567ef
Refactor TestUser in SerializationScopeNameTest
...
Use the same base class we use for other test models
2015-03-23 13:44:30 -04:00
Mateo Murphy
b6951809b0
Add test for required fields
2015-03-22 20:43:57 -04:00
Mateo Murphy
946d1dba14
Remove debug include
2015-03-22 20:43:56 -04:00
Mateo Murphy
33f3a88ba0
Implement included and id and type as per spec
2015-03-22 20:43:56 -04:00
Mateo Murphy
d82c599c68
Always use plural for linked types
...
Although spec is agnostic about inflection rules, examples given are plural
2015-03-22 20:43:11 -04:00
Mateo Murphy
0f55f21266
Update format of links
2015-03-22 20:41:20 -04:00
Mateo Murphy
da86747a3e
Use symbol for root in jsonapi, fix tests
2015-03-22 20:38:29 -04:00
Guillermo Iguaran
b68d7f4826
Merge pull request #852 from mateomurphy/serializer-options-fix
...
Fix options merge order in `each_association`
2015-03-22 18:54:07 -05:00
Mateo Murphy
03372ea61d
Fix options merge order in each_association
...
Custom association serializers were getting clobbered when using an each serializer.
2015-03-20 00:22:46 -04:00
Mateo Murphy
ca985e1afd
Use association value for determining serializer used
...
Ensures overridden association value works when orignal association does not return a result.
2015-03-19 23:28:00 -04:00
Alexandre de Oliveira
af81a403e3
Passes serializer options down into associations
2015-03-11 16:37:14 -03:00
Alexandre de Oliveira
bcd3844e58
Stores passed in options in array serializers
...
This is supported in single serializers. This adds support for passing
options from array serializers to each serializer in it.
2015-03-11 16:14:09 -03:00
Guillermo Iguaran
73aeba4177
Merge pull request #836 from rails-api/stores-passed-in-options
...
Makes passed in options accessible inside serializers
2015-03-11 13:21:36 -05:00
Alexandre de Oliveira
48650ecf7e
Makes passed in options accessible inside serializers
...
In some cases, we want to pass arguments from the controller and we want
to serializer a resource according to that. This allows serializers to
use the `options` method to retrieve whatever was passed in via
arguments.
2015-03-11 14:53:57 -03:00
Robbie Pitts
ad5677c4ec
Make json api adapter 'include' option accept an array, accommodate comma delimited string for legacy reasons
2015-03-11 10:01:44 -04:00
Guillermo Iguaran
d55f3b33b4
Merge pull request #811 from mateomurphy/scope
...
Reimplement serialization scope and scope_name
2015-03-10 10:16:06 -05:00
Alexandre de Oliveira
3389218fd3
Merge pull request #725 from ggordon/has_one_support
...
Support has_one to be compatible with 0.8.x
2015-03-05 15:08:25 -08:00
Alexandre de Oliveira
32343d4575
Merge pull request #822 from bf4/fix_has_one
...
Replace has_one with attribute in template
2015-03-03 11:13:29 -08:00
Gary Gordon
c6044286ef
Workaround order dependent test failure
2015-03-01 13:47:40 -05:00
Gary Gordon
651b99f22e
Support has_one to be compatible with 0.8.x
...
Update README and CHANGELOG
2015-03-01 13:47:34 -05:00
Alexandre de Oliveira
77fb050d24
Merge pull request #821 from wjordan/patch-1
...
Fix explicit serializer for associations
2015-03-01 08:46:27 -05:00
Alexandre de Oliveira
3505bc64a3
Merge pull request #798 from donbobka/feature/fix_lost_test
...
Fix lost test `test_include_multiple_posts_and_linked`
2015-03-01 08:41:13 -05:00
Benjamin Fleischer
79653ac733
Replace has_one with attribute in template
2015-02-25 14:20:18 -06:00
Will Jordan
f4eb33d6e9
Update test_includes_linked_comments with correct expected result
2015-02-24 18:46:04 -08:00
Mateo Murphy
232e367560
Add serialization_scope_name_test
2015-02-12 17:48:43 -05:00
Joao Moura
8a432ad2b3
Adding cache support to version 0.10.0
...
It's a new implementation of cache based on ActiveSupport::Cache.
The implementation abstracts the cache in Adapter class on a
private method called cached_object, this method is intended
to be used on Adapters inside serializable_hash method in order
to cache each instance of the object that will be returned by
the serializer.
Some of its features are:
- A different syntax. (no longer need the cache_key method).
- An options argument that have the same arguments of ActiveSupport::Cache::Store, plus a key option that will be the prefix of the object cache on a pattern "#{key}-#{object.id}".
- It cache the objects individually and not the whole Serializer return, re-using it in different requests (as a show and a index method for example.)
2015-02-02 14:53:34 -02:00
Vladimir Lyzo
54d6696e7c
Fix lost test test_include_multiple_posts_and_linked
2015-01-31 19:44:22 +03:00
Guillermo Iguaran
42644544e1
Merge pull request #792 from rails-api/association-overrides
...
Association overrides
2015-01-30 09:01:49 -05:00
Carles Jove i Buxeda
637113ecd5
add to_param for correct URL generation
2015-01-30 11:08:08 +01:00
Alexandre de Oliveira
e47231cdc8
Support overriding association methods
...
You can override associations to define custom scope on them.
2015-01-29 16:52:18 -02:00
Nicolás Hock Isaza
1d7d9fd6aa
Fix nested include attributes
...
When the requests asked for a nested attribute in the `include` and it's
missing or empty, don't break because the type of the object can't be
determined.
If the request is for a collection and none of the elements has the
attribute, it will not be added to the `linked` key, similar to what
happens with simple includes.
2015-01-13 14:49:58 -05:00
Guillermo Iguaran
22202a115a
Lets keep the assert_equal without parens for consistency.
2015-01-11 16:21:20 -05:00
Robbie Pitts
b626ec8f14
Spec for linked resource type name demodulization
2015-01-11 16:10:02 -05:00
Alexandre de Oliveira
6eb75af96b
Merge pull request #696 from ggordon/explicit_serializer
...
Explicitly set serializer for associations
2015-01-06 09:57:07 -02:00
Alexandre de Oliveira
87f817943a
Merge pull request #700 from arenoir/sparse_fieldsets
...
sparse fieldsets
2015-01-06 09:38:51 -02:00
Alexandre de Oliveira
bd27da1b76
Adds support for meta attribute
...
Currently, 0.10.0.pre doesn't support `meta` option in `render`. This
way, there's no way to support features such as pagination. `0.9` had
this feature in place.
This adds support for it, as well as fixes small things in README.md.
This won't support `meta` in array responses because arrays don't have
keys, obviously. Also, the response should have a `root` key, otherwise
no `meta` will be included.
In some cases, for example using JsonApi, ArraySerializer will result in
a response with a `root`. In that case, `meta` will be included.
2015-01-05 02:56:33 -02:00
Aaron Renoir
2ed52f96a6
merge upstream update fieldset
2014-11-13 17:45:47 -08:00
Alexandre de Oliveira
2f5626d616
Fixes nested has_many links in JSONAPI
...
When linked resource had has_many links, all of them would use the
association from the first resource, causing all of the items to build
`links` with the same associations.
This fixes it by iterating over the serializers, not just the
attributes array.
2014-11-13 16:38:47 -02:00
Gary Gordon
5560b49098
Allow overriding the adapter with render option
...
Make it easy to use multiple adapters in an app.
use "adapter: false" to not use ams
make a test override config.adapter
2014-11-13 10:23:19 -05:00
Gary Gordon
9f9715801a
Explicitly set serializer for associations
...
Document specifying serializer for assocaition
2014-11-13 10:17:59 -05:00
Gary Gordon
08716d20c9
Rename attribute with :key (0.8.x compatibility)
2014-11-13 08:03:22 -05:00
Alexandre de Oliveira
ac37570bff
Merge pull request #728 from rails-api/linked-resources-use-type-as-key
...
Use type as key for linked resources
2014-11-13 10:53:59 -02:00
Alexandre de Oliveira
4af02021ac
Merge pull request #703 from ggordon/specify_serializer_from_controller
...
Support serializer and each_serializer options in renderer
2014-11-12 20:09:51 -02:00
Alexandre de Oliveira
7333f20285
Use type as key for linked resources
...
If type is `author` but the association is called `writer`, the linked
resource key should be called `authors`, e.g
{
...
linked: {
authors: [{
...
}]
}
...
}
2014-11-12 20:03:25 -02:00
Alexandre de Oliveira
91b3fba509
Includes links inside of linked resources
...
According to
http://jsonapi.org/format/#document-structure-resource-objects ,
> Resource objects have the same internal structure, regardless of
> whether they represent primary or linked resources.
And then
http://jsonapi.org/format/#document-structure-resource-object-attributes ,
> There are four reserved keys in resource objects:
>
> "id"
> "type"
> "href"
> "links"
This commits includes `links` inside of linked resources.
2014-11-12 15:44:54 -02:00
Alexandre de Oliveira
971f501e55
Bugfix: include nested has_many association
...
Currently, doing `include: author.bio` would work correctly, but not for
has_many associations such as `include: author.roles`. This fixes it.
The problem was basically that we were not handling arrays for has_many linked,
as happens for ArraySerializers.
2014-11-11 14:35:00 -02:00
Gary Gordon
d97b2f5005
Fix infinite recursion
...
The method for testing whether to include an association was causing
an infinite loop when two models referenced each other.
2014-11-07 10:03:31 -05:00
Mike A. Owens
58b6c4a6b7
Allow for the implicit use of ArraySerializer when :each_serializer is specified.
2014-11-07 09:39:36 -05:00
Aaron Renoir
fc1562c04a
add fields to adapter initialize function, pull in master, add tests using includes with fields
2014-11-05 18:10:37 -08:00
Aaron Renoir
c9c58e31e5
merge upstream/master
2014-11-05 16:47:15 -08:00
Gary Gordon
c84430cdad
Support serializer and each_serializer in render json
2014-11-05 15:10:14 -05:00
Gary Gordon
d5bae0c2f0
Include 'linked' member for json-api collections
...
The options passed to the render are partitioned into adapter options
and serializer options. 'include' and 'root' are sent to the adapter,
not sure what options would go directly to serializer, but leaving this
in until I understand that better.
2014-11-03 17:13:55 -05:00
Guillermo Iguaran
3bba334cf8
JSON-API: Don't include linked section if associations are empty
2014-10-31 14:30:59 -05:00
Guillermo Iguaran
2d21a8e83f
Add type when association name is different than objects type
2014-10-31 01:54:13 -05:00
Guillermo Iguaran
19ac139880
Handle correctly null associations
...
null belongs_to associations are now serialized as nil instead
of raise an error during serialization.
2014-10-30 09:35:05 -05:00
Alexandre de Oliveira
baf3db1365
Merge pull request #691 from jacob-s-son/fix-embed-option-for-associations
...
Fix embed option for associations
2014-10-29 18:41:59 -02:00
Aaron Renoir
be54e0bc4f
remove serializer dependency from fieldset
2014-10-27 15:24:19 -07:00
Aaron Renoir
34f08477e4
fix tests, but need to understand how the serializer class attribute _associations was getting changed.
2014-10-26 14:41:14 -07:00
Aaron Renoir
39bee48ae6
implement sparse fieldsets http://jsonapi.org/format/#fetching-sparse-fieldsets
2014-10-26 13:04:14 -07:00
Edgars Jekabsons
f9b7c74235
Renamed embed test to have "test" suffix
...
Fixed reference to association options
2014-10-22 15:30:44 +03:00
Guillermo Iguaran
5f198667be
Fix support for custom root in JSON-API adapter
2014-10-22 04:01:12 -03:00
Guillermo Iguaran
7c030314cb
Serialize ids as strings in JSON-API adapter
2014-10-15 18:56:49 -05:00
Guillermo Iguaran
557b56a50e
Refactor adapters to implement support for array serialization
2014-10-15 17:35:50 -05:00
Guillermo Iguaran
b91a86b401
Add test for serialization for adapters with root by default
2014-10-14 12:42:21 -05:00
Steve Klabnik
099f773a65
Merge pull request #625 from JordanFaust/feature/url-dsl
...
Add DSL for urls
2014-10-14 11:47:14 -04:00
Steve Klabnik
410eacc30e
Merge pull request #677 from ride/embed-ids-option
...
Add support for embed: :ids option for in associations
2014-10-14 11:39:09 -04:00
Steve Klabnik
341cca7d8a
Merge pull request #681 from quainjn/inherited-serializer
...
Check superclasses for Serializers
2014-10-14 11:36:02 -04:00
Jake Quain
c0166f3026
Check superclasses for Serializers
2014-10-13 17:39:54 -06:00
NullVoxPopuli
7338b62b02
add support for root keys
...
remove debugging gem
fix white space
2014-10-13 13:27:09 -04:00
Guillermo Iguaran
188336522f
Add support for embed: :ids option for in associations
2014-10-10 16:48:55 -05:00
Alex Genco
0eed2b051a
Add "_test" suffix to JsonApi::HasManyTest filename.
...
"rake test" was previously skipping this file because it didn't have the
proper suffix.
2014-09-14 13:02:09 -07:00
Jordan Faust
ad0859e262
Add DSL for urls
2014-09-01 13:44:22 -05:00
Tema Bolshakov and Dmitry Myaskovskiy
71a43a432a
Pass options to associations
2014-08-29 20:16:11 +04:00
Tema Bolshakov and Dmitry Myaskovskiy
ff37b6260d
test for json adapter
2014-08-29 19:40:01 +04:00
Tema Bolshakov
b4a313e6d8
Merge remote-tracking branch 'upstream/master' into feature/adapter
2014-08-29 12:55:20 +04:00
Tema Bolshakov
e45e5a82b7
Remove 'Adapter' suffix from adapters since they are in Adapter:: namespace
2014-08-29 11:40:56 +04:00
Tema Bolshakov
6bb4501f67
JsonApi adapter: serialize association
2014-08-29 11:37:27 +04:00
Tema Bolshakov
6496b08464
rename simple adapter to json
2014-08-29 11:01:39 +04:00
Tema Bolshakov
3dd4928279
* Do not ingerit array serializer from Serializer
...
* Tests for ArraySerializer
2014-08-29 10:58:14 +04:00
Tema Bolshakov
c1fdfc1cdc
First try to implement ArraySerializer
2014-08-28 19:16:24 +04:00
Tema Bolshakov
597765e3b0
start implementing json_api adapter to understand how associations should work
2014-08-28 18:55:27 +04:00
Tema Bolshakov
466c7d5dd8
Wrap association into Serializers
2014-08-28 18:46:19 +04:00
Arthur Neves
c8d9ee4ae3
Fix rails 4.0.x build
2014-08-27 10:53:34 -04:00
Tema Bolshakov
fa4ee9d645
Add Serializer#associations
2014-08-27 11:21:01 +04:00
Tema Bolshakov
b1f7a5ccda
Move Adapter.adapter_for to Serializer.adapter
2014-08-27 11:02:39 +04:00
Tema Bolshakov
a6f9dae560
Concrete adapter should provide serializable hash for Adapter#to_json method
2014-08-27 09:33:14 +04:00
Tema Bolshakov
2c7906e9ff
Test for NullAdapter#serializable_hash
2014-08-27 09:15:54 +04:00
Tema Bolshakov
7b7d4d8907
Test for SimpleAdapter#serializable_hash
2014-08-27 09:15:07 +04:00
Tema Bolshakov
553c470e10
Serializer should be available wiithing adapter to inspect attributes and assotions
2014-08-27 09:09:01 +04:00
Tema Bolshakov
6cc4fa0258
* Configure adapter using ActiveModel::Serializer.config.adapter
...
* Get adapter instance using ActiveModel::Serializer::Adapter.adapter_for(serializer)
2014-08-27 09:05:28 +04:00
Tema Bolshakov
56725b45a6
Add NullAdapater
2014-08-27 08:41:45 +04:00
Tema Bolshakov
f00fe5595d
* Rename NullAdapter to SimpleAdapter
...
* Introduce abstract Adapter class
* Organaze test structure to match convemtions
2014-08-27 08:21:08 +04:00
Tema Bolshakov
a54813806d
Tests for ActiveModel::Serializer.serializer_for for not array serializer
2014-08-26 13:27:46 +04:00
Tema Bolshakov
d39a3e0aec
serializer_for Array
2014-08-26 12:50:47 +04:00
Jordan Faust
00f7cab864
Add DSL for assocations
2014-08-23 15:20:48 -05:00
Steve Klabnik
970b542549
Implement basic rendering
...
Woo actioncontroller
2014-07-09 17:52:31 -04:00
Steve Klabnik
1ea83c8bee
Implement a NullAdapter.
...
This adapter basically doesn't do anything, and just serializes
the attributes into plain old JSON.
2014-07-09 16:51:30 -04:00
Steve Klabnik
c6eea916ad
Move serializer tests into their own directory.
...
It'd be nice to keep some hygene here.
2014-07-09 16:19:02 -04:00
Steve Klabnik
729a823868
Getting started: attributes.
...
Super super basic collection of attributes. Nothing fancy.
2014-07-09 16:16:39 -04:00
Steve Klabnik
4fc0f679df
Add generators.
...
This seemed like the easiest place to start.
2014-07-05 12:35:29 -04:00
Steve Klabnik
a5107b32e2
Set up the test helper and Gemfile.
...
Now Travis will build across all the Rails-es.
2014-07-05 12:03:48 -04:00
Steve Klabnik
99e3d0f70b
Set up minitest
2014-07-05 11:55:45 -04:00