-
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
Remove duplicate test helper #1161
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
class Minitest::Test | ||
def before_setup | ||
ActionController::Base.cache_store.clear | ||
module SerializationTesting | ||
private | ||
|
||
def generate_cached_serializer(obj) | ||
ActiveModel::SerializableResource.new(obj).to_json | ||
end | ||
|
||
# Aliased as :with_configured_adapter to clarify that | ||
# this method tests the configured adapter. | ||
# When not testing configuration, it may be preferable | ||
# to pass in the +adapter+ option to <tt>ActiveModel::SerializableResource</tt>. | ||
# e.g ActiveModel::SerializableResource.new(resource, adapter: :json_api) | ||
def with_adapter(adapter) | ||
old_adapter = ActiveModel::Serializer.config.adapter | ||
ActiveModel::Serializer.config.adapter = adapter | ||
yield | ||
ensure | ||
ActiveModel::Serializer.config.adapter = old_adapter | ||
end | ||
alias_method :with_configured_adapter, :with_adapter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the comment at the top of the method answer that question? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before SerializableResource, the only way to specify an adapter was global, as an option to render, or by building the serializer and adapter yourself.. now we don't need global quite as much There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I got it. I was reading that as "do stuff with the adapter I'm providing, that I have given a specific configuration", instead of "do stuff with this adapter by setting it as the configured adapter". |
||
end | ||
|
||
class Minitest::Test | ||
def before_setup | ||
ActionController::Base.cache_store.clear | ||
end | ||
|
||
include SerializationTesting | ||
end |
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.
👍