Commit Graph

602 Commits

Author SHA1 Message Date
mecampbellsoup
402883d84f Fix Travis lint offenses 2017-06-14 13:35:00 -04:00
mecampbellsoup
92e9a66e97 Amend tests to always include all pagination keys 2017-06-13 12:35:55 -04:00
mecampbellsoup
ff71ef26eb Amend pagination controller specs 2017-06-05 18:41:15 -04:00
mecampbellsoup
d8e983604b Clarify naming of expected response w/ pagination but empty data 2017-06-05 17:51:38 -04:00
mecampbellsoup
7387266c37 Always display self, first, last pagination links 2017-06-05 17:26:41 -04:00
Christian
a89e78c655 Allow referencing sideloaded include by key. (#2136)
* If a `key` is set on the reflection use the `key` instead of `name`.
This ensures that associations with a key set are still included.
2017-05-18 15:59:14 -05:00
Grey Baker
be7ee70376 Allow serialized ID to be overwritten for belongs-to relationships
If the `id` attribute for a class isn't taken directly from the object when
serializing it, it may be desirible for other classes that serialize a
relationship with that class to overwrite the relationship IDs they serialize.

For example, suppose we have:

```(ruby)
class Repo < Model
  attributes :id, :github_id, :name
  associations :configs
end

class Config < Model
  attributes :id
  belongs_to :repo
end

class RepoSerializer < ActiveModel::Serializer
  attributes :id, :name

  has_many :update_configs

  def id
    object.github_id
  end
end

class ConfigSerializer < ActiveModel::Serializer
  attributes :id
  belongs_to :repo
end
```

In the above example, serializing a list of `Repo`s will give the `github_id`
for each one, but serializing a `Config` will give the `id` for its parent repo.

Ideally AMS would inspect the `RepoSerializer` when serializing the `Config`,
and realise it can't just output the foreign key. Unfortunately, getting the
serialization class for the child repo currently requires loading the record
(via evaluating `lazy_assocation`), and loses the performance benefit of the
existing `belongs_to?` path. Instead, I've opted to use
`read_attribute_for_serialization` instead of `object.send` to fetch the
serialized foreign key. This allows the serialized relationship ID to be
overwritten using

```(ruby)
class ConfigSerializer < ActiveModel::Serializer
  ...

  def repo_id
    object.repo.github_id
  end
end
```
2017-05-13 15:22:18 +01:00
Benjamin Fleischer
73eae19b3d Return null resource object identifier for blank id
Also, fix test where attributes were included when id was ""

```
  1) Failure:
  ActionController::Serialization::AdapterSelectorTest#test_render_using_adapter_override
  [test/action_c$ntroller/adapter_selector_test.rb:53]:
  --- expected
  +++ actual
  @@ -1 +1 @@
  -"{\"data\":{\"id\":\"\",\"type\":\"profiles\",\"attributes\":{\"name\":\"Name 1\",\"description\":\"Description 1\"}}}"
  +"{\"data\":null}"
```
2017-04-30 23:28:08 -05:00
Manuel Thomassen
273b7e7f30 belongs_to causes unnecessary db hit 2017-04-30 18:11:37 -05:00
Benjamin Fleischer
876190440f Update reflection tests 2017-04-30 16:39:25 -05:00
Benjamin Fleischer
ff5ab21a45 Make Association totally lazy 2017-04-23 18:40:46 -05:00
Benjamin Fleischer
7697d9f5ec Refactor: introduce lazy association 2017-04-23 17:53:00 -05:00
Benjamin Fleischer
fad4ef1046 Refactor reflection building of association 2017-04-23 14:19:04 -05:00
Benjamin Fleischer
758e44e6e2 Style fixes 2017-04-22 22:10:43 -05:00
Benjamin Fleischer
c13354c4e8 Add test todos before I forget 2017-04-22 22:08:23 -05:00
Benjamin Fleischer
b4cef58e98 Correct tests since reflections changes 2017-04-22 22:08:20 -05:00
Benjamin Fleischer
810229656d Test Reflection value/include_data 2017-04-22 22:07:02 -05:00
Benjamin Fleischer
8440455002 Correct tests since reflections changes 2017-04-22 22:06:59 -05:00
Benjamin Fleischer
e07613b63f Assert mutating reflection is not thread-safe 2017-04-22 22:06:21 -05:00
Benjamin Fleischer
629aa8c7b1 Correct tests since reflections changes 2017-04-22 22:06:08 -05:00
Benjamin Fleischer
1ef7c7d35b Add reflection tests 2017-04-22 22:01:54 -05:00
Benjamin Fleischer
81a9fbd1c3 Merge pull request #2046 from leonelgalan/bug_filter_parameters
Fixes bug in Test::Schema when using filter_parameters
2017-02-16 11:55:23 -06:00
Leonel Galan
e7c79b1f49 Move Rails.application.config into configure block for test rails app. 2017-02-06 15:52:53 -05:00
Leonel Galan
7b9d71e99b Fixes bug in Test::Schema when using filter_parameters 2017-02-06 14:58:36 -05:00
Benjamin Fleischer
93ca27fe44 Merge 0-10-stable into master (to fix breaking change). (#2023)
* Merge pull request #1990 from mxie/mx-result-typo

Fix typos and capitalization in Relationship Links docs [ci skip]

* Merge pull request #1992 from ojiry/bump_ruby_versions

Run tests by Ruby 2.2.6 and 2.3.3

* Merge pull request #1994 from bf4/promote_architecture

Promote important architecture description that answers a lot of questions we get
Conflicts:
	docs/ARCHITECTURE.md

* Merge pull request #1999 from bf4/typos

Fix typos [ci skip]

* Merge pull request #2000 from berfarah/patch-1

Link to 0.10.3 tag instead of `master` branch

* Merge pull request #2007 from bf4/check_ci

Test was failing due to change in JSON exception message when parsing empty string

* Swap out KeyTransform for CaseTransform (#1993)

* delete KeyTransform, use CaseTransform

* added changelog

Conflicts:
	CHANGELOG.md

* Merge pull request #2005 from kofronpi/support-ruby-2.4

Update jsonapi runtime dependency to 0.1.1.beta6

* Bump to v0.10.4

* Merge pull request #2018 from rails-api/bump_version

Bump to v0.10.4 [ci skip]
Conflicts:
	CHANGELOG.md

* Merge pull request #2019 from bf4/fix_method_redefined_warning

Fix AMS warnings

* Merge pull request #2020 from bf4/silence_grape_warnings

Silence Grape warnings

* Merge pull request #2017 from bf4/remove_warnings

Fix mt6 assert_nil warnings

* Updated isolated tests to assert correct behavior. (#2010)

* Updated isolated tests to assert correct behavior.
* Added check to get unsafe params if rails version is great than 5

* Merge pull request #2012 from bf4/cleanup_isolated_jsonapi_renderer_tests_a_bit

Cleanup assertions in isolated jsonapi renderer tests a bit

* Add Model#attributes helper; make test attributes explicit

* Fix model attributes accessors

* Fix typos

* Randomize testing of compatibility layer against regressions

* Test bugfix

* Add CHANGELOG

* Merge pull request #1981 from groyoh/link_doc

Fix relationship links doc
Conflicts:
	CHANGELOG.md
2017-01-10 02:28:50 -06:00
Benjamin Fleischer
c52af54b4e Improve tests found by assert_nil 2017-01-06 23:17:43 -06:00
Benjamin Fleischer
4dfbe2747b Fix test bug found by assert_nil 2017-01-06 22:49:50 -06:00
Benjamin Fleischer
6acb4055c9 Fix MT6 assert_nil warnings 2017-01-06 22:06:23 -06:00
Benjamin Fleischer
98194cc0be Merge pull request #2020 from bf4/silence_grape_warnings
Silence Grape warnings
2017-01-06 23:05:45 -05:00
Benjamin Fleischer
b620c275e5 Silence Grape warnings 2017-01-06 17:18:08 -06:00
Benjamin Fleischer
40489fa8a2 Fix method redefined warning 2017-01-06 17:14:56 -06:00
Benjamin Fleischer
6cf84c11e0 Less strict exception matching 2016-12-24 21:29:46 -06:00
Benjamin Fleischer
4394f76b86 Cleanup assertions in isolated jsonapi renderer tests a bit 2016-12-24 21:28:15 -06:00
Ankit Shah
f246741cc5 Updated isolated tests to assert correct behavior. (#2010)
* Updated isolated tests to assert correct behavior.
* Added check to get unsafe params if rails version is great than 5
2016-12-24 20:34:07 -06:00
Benjamin Fleischer
c1fc0e4371 Handle different messages from different versions of JSON gem 2016-12-23 11:14:59 -06:00
Benjamin Fleischer
05430fb233 Fix typos
```
go get -u github.com/client9/misspell/cmd/misspell
misspell  -w -q -error -source=text {app,config,lib,test}/**/*
```

>   workers   = flag.Int("j", 0, "Number of workers, 0 = number of CPUs")
>   writeit   = flag.Bool("w", false, "Overwrite file with corrections (default is just to display)")
>   quietFlag = flag.Bool("q", false, "Do not emit misspelling output")
>   outFlag   = flag.String("o", "stdout", "output file or [stderr|stdout|]")
>   format    = flag.String("f", "", "'csv', 'sqlite3' or custom Golang template for output")
>   ignores   = flag.String("i", "", "ignore the following corrections, comma separated")
>   locale    = flag.String("locale", "", "Correct spellings using locale perferances for US or UK.  Default is to use a neutral variety of English.  Setting locale to US will correct the British spelling of 'colour' to 'color'")
>   mode      = flag.String("source", "auto", "Source mode: auto=guess, go=golang source, text=plain or markdown-like text")
>   debugFlag = flag.Bool("debug", false, "Debug matching, very slow")
>   exitError = flag.Bool("error", false, "Exit with 2 if misspelling found")
2016-12-11 23:41:23 -06:00
L. Preston Sego III
0422a1e772 Swap out KeyTransform for CaseTransform (#1993)
* delete KeyTransform, use CaseTransform

* added changelog
2016-12-07 10:49:38 -05:00
Benjamin Fleischer
f8ca912de8 Add failing test for AMS::Model accessor vs. attributes mutation 2016-12-04 19:33:39 -06:00
Benjamin Fleischer
80af763d2e Make test attributes explicit
- Organize test poros with associations and by serializer
- Freeze derived attributes/associations against mutation
- Cleanup PORO fixtures
2016-12-04 19:33:39 -06:00
Benjamin Fleischer
772b7999c5 Better AMS Model attributes interface 2016-11-21 09:14:26 -06:00
L. Preston Sego III
d31d741f43 Make serializer lookup configurable (#1757) 2016-11-16 18:38:40 +01:00
Yohan Robert
d0de53cbb2 Fix namespace lookup for collections and has_many (#1973) 2016-11-15 08:35:58 -05:00
L. Preston Sego III
b29395b0ac This adds namespace lookup to serializer_for (#1968)
* This adds namespace lookup to serializer_for

* address rubocop issue

* address @bf4's feedback

* add docs

* update docs, add more tests

* apparently rails master doesn't have before filter

* try to address serializer cache issue between tests

* update cache for serializer lookup to include namespace in the key, and fix the tests for explicit namespace

* update docs, and use better cache key creation method

* update docs [ci skip]

* update docs [ci skip]

* add to changelog [ci skip]
2016-11-09 07:57:39 -05:00
Benjamin Fleischer
c69855bfaa Improve readability of relationships test (#1904)
* Really fix intermittent relationship test failures

* Unify the two JSON API relationship test files

I accidentally introduced the duplication when
merging
https://github.com/rails-api/active_model_serializers/pull/1543#issuecomment-193118782
and they've evolved separately since then.

They both have some value and need to be combined.

* Resolve duplicate tests from diverged tests files

* No longer test Association/Relationship interface directly
2016-09-26 09:23:40 -04:00
Lee Richmond
2145540795 Add include_data :if_sideloaded (#1931)
For JSONAPI, `include_data` currently means, "should we populate the
'data'" key for this relationship. Current options are true/false.

This adds the `:if_sideloaded` option. This means "only
populate the 'data' key when we are sideloading this relationship." This
is because 'data' is often only relevant to sideloading, and causes a
database hit.

Addresses https://github.com/rails-api/active_model_serializers/issues/1555
2016-09-25 12:57:19 -04:00
L. Preston Sego III
6ed499f38e added active record benchmark (#1919)
* added active record benchmark

* address bf4's feedbock

* fix spacing
2016-09-24 16:39:29 -04:00
Lee Richmond
a77dfdaa85 Ensure valid jsonapi when blank relationship (#1930)
If you specify include_data false, and do not have any links for this
relationship, we would output something like:

`{ relationships: { comments: {} } }`

This is not valid jsonapi. We will now render

`{ relationships: { comments: { meta: {} } } }`

Instead.

Relevant jsonapi spec: http://jsonapi.org/format/#document-resource-object-relationships
2016-09-19 14:10:50 -04:00
L. Preston Sego III
810efb838d add bm_adapter (#1914) 2016-09-13 11:20:20 -04:00
Lee Richmond
11bd778f17 Merge pull request #1912 from richmolj/generator
Ensure generator picks up ApplicationSerializer
2016-09-06 12:42:37 -07:00
Lee Richmond
2ea8bb7f40 Merge pull request #1917 from richmolj/disable_pagination_links
Disable pagination links via config
2016-09-06 12:41:18 -07:00
Lee Richmond
19b5abf66e Disable pagination links via config 2016-09-06 15:06:54 -04:00
Lee Richmond
3f16b75a68 Ensure generator picks up ApplicationSerializer
ApplicationSerializer could exist, but not be loaded. So, we check
existence by looking at the filesystem instead of defined?.

Fixes https://github.com/rails-api/active_model_serializers/issues/1890
2016-09-05 19:00:25 -04:00
Lee Richmond
07dab5a054 Add helpful testing gems
Addresses https://github.com/rails-api/active_model_serializers/pull/1911#discussion_r77548416
2016-09-05 18:27:58 -04:00
Benjamin Fleischer
1d4cd6f104 Fix intermittent test failures by not mutating global state
e.g.

https://ci.appveyor.com/project/bf4/active-model-serializers/build/415/job/qs8895cvla8fl0rf
 1) Failure:
 ActiveModel::Serializer::Adapter::JsonApi::RelationshipTest#test_relationship_including_data_explicit
 [C:/projects/active-model-serializers/test/adapter/json_api/relationships_test.rb:186]:
 --- expected
 +++ actual
 @@ -1 +1 @@
 -{:data=>{:id=>"1337", :type=>"authors"}, :meta=>{:name=>"Dan Brown"}}
 +{:data=>{:id=>"1337", :type=>"authors"

https://travis-ci.org/rails-api/active_model_serializers/jobs/156678147
  1) Failure:
  ActiveModel::Serializer::Adapter::JsonApi::RelationshipTest#test_relationship_with_everything
  [/home/travis/build/rails-api/active_model_serializers/test/adapter/json_api/relationships_test.rb:200]:
  --- expected
  +++ actual
  @@ -1 +1 @@
  -{:data=>[{:id=>"1337", :type=>"likes"}],
  :links=>{:related=>{:href=>"//example.com/likes/1337",
  :meta=>{:ids=>"1337"}}}, :meta=>{:liked=>true}}
  +{:data=>[{:id=>"1337", :type=>"likes"}],
  :links=>{:related=>{:href=>"//example.com/likes/1337",
  :meta=>{:ids=>"1337"}}}}
2016-08-31 19:24:21 -05:00
Benjamin Fleischer
20e394d512 Refactor Association into Field like everything else (#1897)
* Make assocations asserts easier to understand

* Refactor Association into Field like everything else

* Make assocation serializer/links/meta lazier

* Push association deeper into relationship

* Simplify association usage in relationships

* Better naming of reflection parent serializer

* Easier to read association method
2016-08-31 09:35:41 -04:00
Ian C. Anderson
2423ca4999 Support key transformation for Attributes adapter (#1889)
The `:attributes` adapter is the default one, but it did not support
key transformation. This was very surprising behavior, since the
"Configuration Options" page in the guides didn't mention that this
behavior was not supported by the attributes adapter.

This commit adds key transform support to the attributes adapter, and
adds documentation about the default transform for the attributes
adapter (which is `:unaltered`).

This commit also handles arrays when transforming keys, which was needed
in the case where you're serializing a collection with the Attributes
adapter. With the JSON adapter, it was always guaranteed to pass a hash
to the KeyTransform functions because of the top-level key. Since there
is no top-level key for the Attributes adapter, the return value could
be an array.
2016-08-25 15:21:27 -04:00
Benjamin Fleischer
455068d455 Merge pull request #1884 from bf4/simplify_relationship
* Simplify Relationship
2016-08-17 16:18:14 -05:00
L. Preston Sego III
a319fef239 Add tests for fields option demonstrating usage on both attributes and relationships (#1839)
* add test for fields whitelisting relationships, and use the JSON API Include Directive to do the heavy lifting
2016-08-17 16:12:12 -05:00
Benjamin Fleischer
abb15b9622 Simplify Relationship 2016-08-17 15:58:11 -05:00
Benjamin Fleischer
d66e272994 Correct typos 2016-08-16 18:18:58 -05:00
Yevhen Shemet
1896e5a525 ActiveModelSerializers::Model successor initialized with string keys fix (#1881) 2016-08-16 06:49:10 -04:00
Mark Abramov
5f3bdcc87c Use ActiveSupport::Cache.expand_cache_key for cache key expansions (#1878)
* Use ActiveSupport::Cache.expand_cache_key for cache key expansions
2016-08-13 16:59:36 -05:00
L. Preston Sego III
6de3f31b6e Namespace separator setting for json-api and tests (#1874)
Adds jsonapi_namespace_separator configuration

Also:

* Enable getting type from record class without serializer

Needs Followup:

- https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607042 
- https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607734
2016-08-12 12:54:42 -05:00
L. Preston Sego III
aa4d89ab47 remove dynamic class creation where not needed (#1850)
* remove dynamic class creation where not needed
2016-07-18 14:11:09 -05:00
Avon
3ad2457aaf Bugfix/redefine associations on inherited serializers (#1848)
* replace reflection collection type with hash to prevent duplicated associations in some cases

* include tests

* Fix robucup offenses

* Improve test

* Remove usless requirement

* improve tests

* remove custom_options option from Post and InheritedPost serializer

* Improve tests

* update changelog

* update changelog
2016-07-17 16:25:43 -04:00
Yohan Robert
9a206a1f5d Remove nil relationships links (#1833) 2016-07-12 14:02:34 +02:00
Benjamin Fleischer
f4e00dc65d Merge pull request #1815 from dubadub/making-rubocop-happy
Fix code-styling issues from .rubocop_todo.yml

* re: RuboCop: Bulk minor style corrections

* re: RuboCop - hash indention corrections

* re: RuboCop - replace rocket style hashes

* re: RuboCop - get rid of redundant curly braces around a hash parameter

* re: RuboCop - Align the elements of a hash literal if they span more than one line.

* re: RuboCop - Use nested module/class definition instead of compact style.

* re: RuboCop - Suppress of handling LoadError for optional dependencies

* re: RuboCop - use include_ prefix instead of has_

* re: RuboCop - Disable Style/PredicateName rule for public API methods

* re: RuboCop - Remove empty .rubocop_todo.yml

* re: RuboCop - replace rocket style hashes
2016-06-26 22:22:55 -05:00
zaaroth
bcf3358524 Ensuring read_multi works with fragment cache. (#1814)
* Ensuring read_multi works with fragment cache.
2016-06-22 22:33:02 -05:00
Alexey Dubovskoy
800221ed90 re: RuboCop - replace rocket style hashes 2016-06-21 22:08:27 +01:00
Alexey Dubovskoy
ce168f9414 re: RuboCop - use include_ prefix instead of has_ 2016-06-20 22:17:01 +01:00
Alexey Dubovskoy
85f417f8d2 re: RuboCop - Use nested module/class definition instead of compact style. 2016-06-20 22:15:20 +01:00
Alexey Dubovskoy
8a2beacb6f re: RuboCop - Align the elements of a hash literal if they span more than one line. 2016-06-20 22:14:56 +01:00
Alexey Dubovskoy
13015680a7 re: RuboCop - get rid of redundant curly braces around a hash parameter 2016-06-20 22:14:39 +01:00
Alexey Dubovskoy
024b2d51d3 re: RuboCop - replace rocket style hashes 2016-06-20 22:14:12 +01:00
Alexey Dubovskoy
004f1437d8 re: RuboCop - hash indention corrections 2016-06-20 22:13:21 +01:00
Alexey Dubovskoy
f15f6850de re: RuboCop: Bulk minor style corrections 2016-06-20 22:12:16 +01:00
Benjamin Fleischer
1a9c62215a Use with_adapter(&block) to fix failing tests
I missed that the code was changing global state.
2016-06-14 09:46:22 -05:00
Onome
580492282f Fix #1759, Grape integration, adds serialization_context (#4)
* Fix #1759, Grape integration, adds serialization_context

- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).

* Updated Grape tests to include:
- paginated collections
- implicit Grape serializer (i.e. without explicit invocation of `render` helper method)

* Update Changelog with fixes.
2016-06-14 09:46:22 -05:00
Benjamin Fleischer
a7296e8a92 Fix #1759, Grape integration, adds serialization_context
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
2016-06-14 09:45:30 -05:00
Benjamin Fleischer
5017bb7f2e Fix spelling
```
cat <<  'EOF' > .git/hooks/pre-push

bundle exec rake rubocop

if command -v misspell >/dev/null; then
  misspell  -w -error -source=text {app,config,lib,spec,test,docs,bin}/**/* 2>/dev/null
fi

EOF
chmod +x .git/hooks/pre-push
```
2016-06-09 03:41:01 -05:00
Filippos Vasilakis
be01fc8ee7 Pass fields down from constructor 2016-06-09 03:26:52 -05:00
Benjamin Fleischer
cd9689683c Merge branch 'ouvrages-exclude_nil_links' 2016-06-09 02:55:32 -05:00
Benjamin Fleischer
af368af53e Make bencharked model names reflect relationships; fix expected response 2016-06-08 23:40:36 -05:00
Benjamin Fleischer
5375e009e2 Test caching with fragmented key
- on association, fix up assocation logic
- on attribute
2016-06-07 20:26:38 -05:00
Benjamin Fleischer
b8924157d7 Remove remaining fragmented cache class 2016-06-07 03:42:03 -05:00
Benjamin Fleischer
35a7c81034 Fix up caching, especially fragment_cache 2016-06-07 00:52:05 -05:00
Benjamin Fleischer
caf4910b6e Remove controller :assigns warnings/shim 2016-06-04 15:00:51 -05:00
Benjamin Fleischer
913f396bb1 Move adapter cache properties to class level (where they belong). 2016-06-04 15:00:51 -05:00
Benjamin Fleischer
ee518e1856 Remove unnecessary Adapter::Base#cache_attributes 2016-06-01 00:35:11 -05:00
Lucas Hosseini
f48fd2a327 Extract IncludeTree. (#1685) 2016-05-28 10:07:11 -04:00
L. Preston Sego III
7d7329bbcf Merge pull request #1426 from brigade/default-include
Add a default_include_tree config variable to ActiveModel::Serializer
2016-05-26 13:31:53 -04:00
Ben Mills
9cffc10208
Add Rails >= 5.0.beta3 JSON API params parsing (#1751)
This reverts commit 6288203277.
2016-05-26 11:19:23 -06:00
Ben Mills
6288203277 Revert "Add Rails >= 5.0.beta3 JSON API params parsing" (#1751) 2016-05-26 11:17:32 -06:00
Noah Silas
94db09b3f6 Fix RuboCop 0.40 linter errors (#1722)
These errors are breaking the build, which seems to use RuboCop 0.40 [1]
despite the Gemfile.lock pinning rubocop to 0.38.

New lints that I am updating the code style to reflect:

- Style/EmptyCaseCondition: Do not use empty case condition, instead use
  an if expression.

- Style/MultilineArrayBraceLayout: Closing array brace must be on the
  same line as the last array element when opening brace is on the same
  line as the first array element.

- Style/MultilineHashBraceLayout: Closing hash brace must be on the same
  line as the last hash element when opening brace is on the same line
  as the first hash element.

- Style/MultilineMethodCallBraceLayout: Closing method call brace must
  be on the line after the last argument when opening brace is on a
  separate line from the first argument.

[1] https://github.com/bbatsov/rubocop/releases/tag/v0.40.0
2016-05-26 12:58:05 -04:00
Benjamin Fleischer
8a3196d920 Improve jsonapi mime type registration for Rails 5 (#1747) 2016-05-26 10:55:12 -06:00
Ben Woosley
8c18d18cdb Add default_includes configuration
This is useful to set application-wide default behavior - e.g. in
previous versions of AMS the default behavior was to serialize the
full object graph by default - equivalent to the '**' include tree.

Currently just the global setting, but I think this could also work
on a per-serializer basis, with more attention.
2016-05-26 00:16:14 +00:00
Yohan Robert
a701777bd5 Prevent loading association when include_data is set to false (#1710)
This should fix #1707.
2016-05-24 20:46:22 -04:00
cgmckeever
bbed12864d adds polymorphic option to association definition which includes association type in serializer
regen gemlock

regen gemlock

better variable naming

rubocop fixes

adds to changelog

adds empty relationship and has_many polymorph tests

indent

test cleaning

-rubocop

rubocop

rubocop

rubocop

changelog

remove silly .DS

fix roque failure

fix
2016-05-17 12:30:59 -05:00
Benjamin Fleischer
6c321cd862 Assert Schema (#1677)
* Assert Schema

* Fix regression from #1695 where JSONAPI renders empty meta

* Add changelog
2016-05-17 13:22:38 -04:00
Benjamin Fleischer
93cad825b7 Include actual exception message with custom exceptions 2016-05-17 10:32:53 -05:00