Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Follow up to #1535 #1543

wants to merge 1 commit into from

Conversation

groyoh
Copy link
Member

@groyoh groyoh commented Feb 28, 2016

UPDATE: Merged via e30b2a4

Purpose

Follow up to #1535.
Closes #1529.

Changes

@@ -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
Copy link
Member

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...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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 ;)

Copy link
Member Author

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?

end

def create(resource, options = {})
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added deprecation message here.

@bf4
Copy link
Member

bf4 commented Feb 29, 2016

Hey @groyoh good stuff in here, but I think you overdid it a bit. The only interface people should be using is Adapter, Adapter::Base/Null/Json/JsonApi and those can be referenced I think as

# 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 DelegateClass or SimpleDelegator object in order to allow us to add deprecation warnings without subclassing the AMS.

@@ -0,0 +1,85 @@
require 'test_helper'
Copy link
Member Author

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.

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"
Copy link
Member

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 it works 😄

# 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'.
Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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.

@groyoh groyoh force-pushed the follow_up_1535 branch 3 times, most recently from 0f789e4 to 8e0b877 Compare February 29, 2016 05:48
- 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
@groyoh
Copy link
Member Author

groyoh commented Feb 29, 2016

@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
Copy link
Member Author

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.

bf4 added a commit that referenced this pull request Mar 7, 2016
Needs followup
- way we deprecate classes to be generalized
  - initialize old json api #1543 (comment)
  - consider restoring ensure #1543 (comment)
@bf4
Copy link
Member

bf4 commented Mar 7, 2016

Merged by e30b2a4

@bf4
Copy link
Member

bf4 commented Mar 7, 2016

Closed via e30b2a4

@bf4 bf4 closed this Mar 7, 2016
@bf4 bf4 mentioned this pull request Mar 7, 2016
bf4 added a commit to bf4/active_model_serializers that referenced this pull request Sep 1, 2016
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.
bf4 added a commit to bf4/active_model_serializers that referenced this pull request Sep 1, 2016
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.
bf4 added a commit to bf4/active_model_serializers that referenced this pull request Sep 4, 2016
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.
bf4 added a commit to bf4/active_model_serializers that referenced this pull request Sep 26, 2016
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.
NullVoxPopuli pushed a commit that referenced this pull request Sep 26, 2016
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants