Commit Graph

357 Commits

Author SHA1 Message Date
João Moura
d3649d5b4e Renaming Error to NoSerializerError 2015-06-26 02:16:35 -03:00
Benjamin Fleischer
e5d1e40dbd Handle special-case of Array serializer with unserializable elements 2015-06-26 02:16:34 -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
189b79523c fixing array rendering when elements doesn't have a serializer 2015-06-26 02:15:42 -03:00
João Moura
d589268f95 adding new tests to cover array and object rendering 2015-06-26 02:15:42 -03:00
João Moura
01a225f0e4 Merge pull request #939 from aaronlerch/default-cache-key
Use a more precise generated cache key
2015-06-26 02:09:28 -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
João Moura
c0a82648d5 Merge pull request #971 from bf4/readd_has_one_to_generator
Restore has_one to generator
2015-06-25 18:37:52 -03:00
João Moura
1bb1724b5d Merge pull request #965 from bf4/serialization_options_default_nil
options fedault valueserializable_hash and as_json
2015-06-25 18:32:52 -03: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
Benjamin Fleischer
2d24dded14 serializable_hash and as_json should take options = nil
per ActiveModel::Serialization#serializable_hash
96bb004fc6/activemodel/lib/active_model/serialization.rb
    def serializable_hash(options = nil)
          options ||= {}

Otherwise, passing in nil to `as_json` or `serializable_hash`
makes things blow up when passing nil into attributes
2015-06-24 11:46:29 -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
867d36a3a3 updating readme and changelog 2015-06-18 19:17:44 -03:00
João Moura
61ac3ad0ff Merge pull request #959 from kangkyu/patch-1
TYPO on README.md
2015-06-17 15:31:29 -03:00
Kang-Kyu Lee
ed818d9fd3 Update README.md
I wonder how `ActiveRecord::Serializer` and `ActiveRecord::Serializers` are different? However I found they have different name between the title and code.
2015-06-17 11:24:48 -07:00
João Moura
bc8fd0a44a Merge pull request #958 from joaomdmoura/spliting-json-adapter
Splitting json adapter into two
2015-06-16 11:54:33 -03:00
João Moura
e321cb366d Getting root key from AR::Relation 2015-06-16 11:36:17 -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
2e46507971 avoiding nil cases when dynamically creating a class 2015-06-15 02:50:06 -03:00
João Moura
8e1214b4c5 force to use flattenJson when dealing with ArraySerializer 2015-06-15 02:48:39 -03:00
João Moura
b2f1947d4a removing unseless root method 2015-06-14 17:24:48 -03:00
João Moura
2bf91a0c0e updating adapters to follow new root logic 2015-06-14 03:25:20 -03:00
João Moura
a0753cb0bc autoloading new flatten son adapter 2015-06-14 03:25:00 -03:00
João Moura
1c3a180a20 disable root as flag option 2015-06-13 15:48:33 -03:00
João Moura
c8fcb60a5d addung fragment_cache method to Adapter::Json 2015-06-13 15:48:33 -03:00
João Moura
5932da64ef creating flatten_json adapter 2015-06-13 15:48:33 -03:00
João Moura
37114e9d5b removing unnecessary root parameter on fragment cache 2015-06-13 15:48:33 -03:00
Alexandre de Oliveira
7fa123bd6b Merge pull request #953 from lsylvester/use-active-model-name-for-type
use model name to determine the type
2015-06-13 15:29:07 -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
João Moura
c2305f0783 Merge pull request #948 from SeyZ/patch-1
AMS supports JSONAPI 1.0 instead of RC4
2015-06-12 17:24:55 -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
Sandro Munda
a865ba53ea AMS supports JSONAPI 1.0 instead of RC4 2015-06-10 14:11:28 +02: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
João Moura
4c7442dd0f Merge pull request #942 from thiagofm/patch-1
Small code styling issue
2015-06-08 17:54:41 -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
35fb9de310 Merge pull request #930 from joaomdmoura/master
Reverting PR #909
2015-05-27 23:38:02 -03:00