-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow up to #1535 #1543
Follow up to #1535 #1543
Conversation
c54adab
to
b0fdb0d
Compare
@@ -1,6 +1,8 @@ | |||
## 0.10.x | |||
|
|||
Breaking changes: | |||
- [#1535](https://github.com/rails-api/active_model_serializers/pull/1535) Move the adapter and adapter folder to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think we do want to re-add the deprecated Adapter classes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, like ArraySerializer -> CollectionSerializer per the RFC https://github.com/rails-api/active_model_serializers/blob/master/docs/rfcs/0000-namespace.md#keeping-compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I realized that afterward. I'm currently working on this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the "ApiObjects" also be re-add or should I simply change the references to match with the ActiveModelSerializers
namespace?
b0fdb0d
to
e6fdeac
Compare
end | ||
|
||
def create(resource, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added deprecation message here.
e6fdeac
to
d06b141
Compare
Hey @groyoh good stuff in here, but I think you overdid it a bit. The only interface people should be using is # lib/active_model/serializer/adapter.rb
ActiveModel::Serializer::Adapter = ActiveModelSerializers::Adapter
# lib/active_model/serializer/adapter/json_api.rb
ActiveModel::Serializer::Adapter::JsonApi = ActiveModelSerializers::Adapter::JsonApi or something like that (would need some requires.).. I think that's a good starting point. Alternative, we can use the |
d06b141
to
1af55a2
Compare
@@ -0,0 +1,85 @@ | |||
require 'test_helper' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was simply moved. Nothing to see here.
1af55a2
to
d935acc
Compare
module Adapter | ||
class JsonApi < DelegateClass(ActiveModelSerializers::Adapter::JsonApi) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater::JsonApi in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::JsonApi" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- typo:
s/Adater/Adapter
- Does this work?
Calling deprecated #{self.class.name} (#{__FILE__}) from #{caller[0..2].join(', '). Please use #{self.class.name.sub('ActiveModel::Serializer', 'ActiveModelSerializers')}
(not tested in terminal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 it works 😄
d935acc
to
505c637
Compare
# AMS::Adapter.register(:my_adapter, MyAdapter) | ||
# @note The registered name strips out 'ActiveModel::Serializer::Adapter::' | ||
# so that registering 'ActiveModel::Serializer::Adapter::Json' and | ||
# 'Json' will both register as 'json'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for all the comments here. Can just be {ActiveModelSerializers::Adapter.register}
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or @see ActiveModelSerializers::Adapter.register
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a @deprecated
tag instead.
0f789e4
to
8e0b877
Compare
- The removed classes and modules were added back with deprecation warning and deprecation test were added for them. - One test was renamed because it contained `__`. - Some tests were refactored. - The ActiveModelSerializers::Deserialization module is now called Adapter instead of ActiveModelSerializers::Adapter. - The changelog was added for rails-api#1535
8e0b877
to
6829069
Compare
@bf4 I took care of all your comments. I expect it to be good to merge 😄 |
@serializer = DeprecatedPostSerializer.new(post) | ||
end | ||
|
||
def test_null_adapter_serialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these tests to have some kind of regression tests. It's not completely reliable but it's better than nothing.
Needs followup - way we deprecate classes to be generalized - initialize old json api #1543 (comment) - consider restoring ensure #1543 (comment)
Merged by e30b2a4 |
Closed via e30b2a4 |
I accidentally introduced the duplication when merging rails-api#1543 (comment) and they've evolved separately since then. They both have some value and need to be combined.
I accidentally introduced the duplication when merging rails-api#1543 (comment) and they've evolved separately since then. They both have some value and need to be combined.
I accidentally introduced the duplication when merging rails-api#1543 (comment) and they've evolved separately since then. They both have some value and need to be combined.
I accidentally introduced the duplication when merging rails-api#1543 (comment) and they've evolved separately since then. They both have some value and need to be combined.
* Really fix intermittent relationship test failures * Unify the two JSON API relationship test files I accidentally introduced the duplication when merging #1543 (comment) 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
UPDATE: Merged via e30b2a4
Purpose
Follow up to #1535.
Closes #1529.
Changes
__
Adater
instead ofActiveModelSerializers::Adapter
.