Benjamin Fleischer
00a47d3da4
Prove CI broken ( #2220 )
...
* Remove appveyor rubygems/bundler stuff
* Try specifying different jdbc adapter
* Attempt to fix failing JRuby test I cannot reproduce
```
bundle exec rake ci
Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
/home/travis/.rvm/rubies/jruby-9.1.9.0/bin/jruby -w -I"lib:lib:test" -r./test/test_helper.rb -w -I"/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/rake-11.3.0/lib" "/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb" "test/**/*_test.rb"
ActiveModelSerializers::Adapter::JsonApi::PaginationLinksTest#test_raises_descriptive_error_when_serialization_context_unset [/home/travis/build/rails-api/active_model_serializers/test/adapter/json_api/pagination_links_test.rb:186]:
[] exception expected, not
Class: <ActiveModelSerializers::Adapter::JsonApi::PaginationLinks::MissingSerializationContextError>
Message: <" JsonApi::PaginationLinks requires a ActiveModelSerializers::SerializationContext.\n Please pass a ':serialization_context' option or\n override CollectionSerializer#paginated? to return 'false'.\n">
---Backtrace---
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/json_api/pagination_links.rb:14:in `block in initialize'
org/jruby/RubyHash.java:1187:in `fetch'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/json_api/pagination_links.rb:13:in `initialize'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/json_api.rb:520:in `pagination_links_for'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/json_api.rb:147:in `success_document'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/json_api.rb:59:in `serializable_hash'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/adapter/base.rb:59:in `as_json'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/serializable_resource.rb:8:in `as_json'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:69:in `block in as_json'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:117:in `call'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:555:in `block in compile'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:505:in `call'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:498:in `block in around'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:343:in `block in simple'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:22:in `block in instrument_rendering'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:79:in `block in notify_render'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:78:in `notify_render'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:21:in `block in instrument_rendering'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:97:in `tag_logger'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:20:in `block in instrument_rendering'
org/jruby/RubyBasicObject.java:1724:in `instance_exec'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:342:in `block in simple'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:497:in `block in around'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:505:in `call'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:778:in `_run_render_callbacks'
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/travis/build/rails-api/active_model_serializers/lib/active_model_serializers/logging.rb:68:in `block in as_json'
/home/travis/build/rails-api/active_model_serializers/test/adapter/json_api/pagination_links_test.rb:187:in `block in test_raises_descriptive_error_when_serialization_context_unset'
Command failed with status (1): [ruby -w -I"lib:lib:test" -r./test/test_helper.rb -w -I"/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/rake-11.3.0/lib" "/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" ]
/home/travis/build/rails-api/active_model_serializers/vendor/bundle/jruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in `<main>'
Tasks: TOP => ci => default => test
(See full trace by running task with --trace)
```
2017-11-13 08:34:56 -06:00
Benjamin Fleischer
3c5e11bb0f
Merge pull request #2216 from rails-api/serialize_resource_with_nil_id
...
Fix: Serialize resource type for unpersisted records (blank id)
2017-11-01 10:36:22 -05:00
Benjamin Fleischer
33ec26fa12
Merge branch 'stratigos-patch-1' into 0-10-stable
2017-10-31 16:46:20 -05:00
Todd Morningstar
0bbeeb384e
Update serializers.md
...
* Add note that any controller reference is acceptable for `serialization_scope`
* Add note about `ActionController::API` and `view_context` set to `nil`, with respect to accessing helpers in a Serializer
* refs #2144
* Update CHANGELOG.md
2017-10-31 17:15:43 -04:00
Benjamin Fleischer
196216b250
Merge pull request #2212 from rails-api/remove_legacy_embeds
...
Remove legacy has_many_embed_ids test [ci skip]
2017-10-31 14:54:02 -05:00
Benjamin Fleischer
51f2643f40
Style
2017-10-31 14:48:27 -05:00
Benjamin Fleischer
9745a2f735
Fix: ResourceIdentifier.for_type_with_id can serialize unpersisted resources
2017-10-31 14:47:55 -05:00
Benjamin Fleischer
5916014b48
Fix: resource object identifier with nil id excludes id
2017-10-31 14:34:30 -05:00
Benjamin Fleischer
92dde58f5f
Assert serializer-defined types are not inflected
2017-10-31 14:31:33 -05:00
Benjamin Fleischer
82e90091fd
Put the similar jsonapi type tests together
2017-10-31 14:29:09 -05:00
Benjamin Fleischer
b439fe69c6
Refactor jsonapi type/id tests to be more explicit
2017-10-31 14:26:05 -05:00
Benjamin Fleischer
e3480345e3
Merge pull request #2211 from rails-api/polymorphic_relationships_require_serializer_instance
...
JSON:API relationship tests no longer show v0.10.5 regression
2017-10-31 13:49:18 -05:00
Benjamin Fleischer
54d40c79e8
Merge pull request #2214 from jmeredith16/undeterminable-json-root
...
Fail if collection type cannot be inferred with json adapter (#2210 )
2017-10-30 16:11:08 -05:00
Joe Meredith
c6a14c9eac
Fail if collection type cannot be inferred with json adapter ( #2210 )
2017-10-30 13:37:37 -04:00
Benjamin Fleischer
1fd324947f
Remove legacy has_many_embed_ids test
2017-10-29 22:50:59 -05:00
Benjamin Fleischer
a0de45a4d8
Fix JSON:API: for_type_and_id should always inflect_type
...
Should Serializer._type ever be inflected?
Right now, it won't be, but association.serializer._type will be inflected.
That's the current behavior.
2017-10-29 21:23:48 -05:00
Benjamin Fleischer
cf29db34c6
Fix JSON:API polymorphic type regression from v0.10.5
2017-10-29 20:15:15 -05:00
Benjamin Fleischer
0fcb8a6cce
Fix polymorphic belongs_to tests; passes on v0.10.5
2017-10-29 19:26:14 -05:00
Benjamin Fleischer
5e1e138d47
Refactor ResourceIdentifier
2017-10-29 17:13:34 -05:00
Vedant Agarwala
4076a480b7
Removed misleading line in README
...
As mentioned in the `master` branch's README, master will not be release ready for now.
Fixes https://github.com/rails-api/active_model_serializers/issues/2163
2017-10-29 16:26:32 -05:00
Nate Pinsky
88367da970
Add warnings about global adapter config to docs ( #2176 )
2017-10-24 17:30:56 -05:00
Dennis Stumm
4d7c2457d7
Fix deserialization of polymorphic relationships ( #2200 )
...
* Classify the relationship type for polymorphic associations
2017-10-07 17:03:38 -05:00
Benjamin Fleischer
715a702f55
Merge pull request #2189 from tagliala/update-jsonapi-renderer-dependency
...
Update version constraint for jsonapi-renderer
2017-09-19 15:32:44 -05:00
Benjamin Fleischer
4a995955ea
Merge pull request #2198 from tagliala/improve-travis-configuration
...
Test against latest stable Ruby and Rails versions
2017-09-19 15:31:57 -05:00
Geremia Taglialatela
ab517d1a2d
Test against latest stable Ruby and Rails versions
...
Also skips Rails 4.1 tests against Ruby 2.4.2 and ruby-head,
because Rails 4.2.8 is the first version of the 4.x series that
officially support Ruby 2.4.
2017-09-19 17:47:52 +02:00
Geremia Taglialatela
1c9214d041
Update version constraint for jsonapi-renderer
2017-09-19 16:57:09 +02:00
Benjamin Fleischer
6a7d864605
Fix CI on 0-10-stable ( #2181 )
...
* Loosen pry, pry-byebug depencency
```
Resolving dependencies...
byebug-9.1.0 requires ruby version >= 2.2.0, which is
incompatible with the current version, ruby 2.1.10p492
```
* Adjust nokogiri version constraint for CI
Update appveyor Ruby to 2.3 to work around:
```
Gem::InstallError: nokogiri requires Ruby version < 2.5, >= 2.2.
An error occurred while installing nokogiri (1.8.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.0'` succeeds before bundling.
```
and not 2.4 since:
https://ci.appveyor.com/project/bf4/active-model-serializers/build/1.0.1052-fix_ci/job/0q3itabsnvnxr83u
```
nokogiri-1.6.8.1-x86-mingw32 requires ruby version < 2.4, which is incompatible with the current version, ruby 2.4.1p111
```
* Include rails gem in Gemfile
(For Rails5)
In Rails5, checking for Rails::Railtie is better
* Rails5 test env requires Rails.application.class.name
rails-42d09f6b49da/railties/lib/rails/application.rb
```ruby
def secret_key_base
if Rails.env.test? || Rails.env.development?
Digest::MD5.hexdigest self.class.name
```
* Reformat exclude matrix to be easier to read
* Simplify jruby-travis config per rails/rails
* Organize .travis.yml per rails/rails
* Allow JRuby failure on Rails 5+; try rails-5 db adapter branch
https://github.com/jruby/activerecord-jdbc-adapter/issues/708
```
uninitialized constant ActiveRecord::ConnectionAdapters::Column::Format
```
see https://travis-ci.org/rails-api/active_model_serializers/jobs/277112008
2017-09-19 05:27:02 -04:00
Benjamin Fleischer
c2fa01624d
Merge pull request #2191 from tagliala/fix-rubocop-offence
...
Fix RuboCop offence
2017-09-17 12:59:12 -05:00
Geremia Taglialatela
4f78319219
Fix RuboCop offence
2017-09-17 19:33:05 +02:00
Benjamin Fleischer
b1de431731
Merge pull request #2179 from drn/enumerator-exception
...
Fix Enumerator.new ArgumentError.
2017-08-29 10:14:25 -05:00
Darren Cheng
967ff8dcc0
Patch Enumerator.new ArgumentError.
2017-08-28 19:38:08 -07:00
Alexandre de Oliveira
1e4d117b99
Merge pull request #2149 from mecampbellsoup/more-pagination-links-by-default
...
Always include self, first, last pagination links
2017-06-14 15:47:30 -03:00
mecampbellsoup
402883d84f
Fix Travis lint offenses
2017-06-14 13:35:00 -04:00
mecampbellsoup
e4b3224c64
Fix indentation mismatch
2017-06-14 12:53:38 -04:00
mecampbellsoup
b7442e741c
Use symbolized keys for json hash
...
They will be converted to strings when rendered as JSON.
2017-06-14 12:52:29 -04:00
Benjamin Fleischer
1539747a59
Merge pull request #2152 from tannerj/0-10-stable
...
Fix dead link in docs/general/rendering
2017-06-13 20:08:29 -05:00
Joel Tanner Jones
622872ae2b
Fix dead link in docs/general/rendering
...
The add_pageination_links.md is dead in docs/general/rendering on the
0-10-stable branch.
2017-06-13 13:28:24 -04:00
mecampbellsoup
92e9a66e97
Amend tests to always include all pagination keys
2017-06-13 12:35:55 -04:00
mecampbellsoup
16e5204eab
Always include pagination keys but set null values when not needed
2017-06-13 12:09:00 -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
Benjamin Fleischer
a5ab62fd18
Merge pull request #2130 from greysteil/allow-id-overwriting
...
Allow serialized ID to be overwritten for belongs-to relationships
2017-05-15 09:24:41 -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
b48aeeef1e
Merge branch 'master' into 0-10-stable
2017-05-01 11:04:46 -05:00
Benjamin Fleischer
dff621e174
Bump to v0.10.6
2017-05-01 10:59:14 -05:00
Benjamin Fleischer
982fe26ee8
Merge pull request #2120 from bf4/allow_customizing_relation_foreign_key
...
Document new reflection options; support :foreign_key [ci skip]
2017-05-01 10:56:35 -05:00
Benjamin Fleischer
ec7b5859f7
Document namespace
2017-05-01 10:25:14 -05:00
Benjamin Fleischer
96028a7b99
Document new reflection options; support :foreign_key
2017-05-01 10:18:13 -05:00