mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Rubocop: Consistent spacing
This commit is contained in:
parent
bdfe13c527
commit
228cc1c92a
@ -1,5 +1,6 @@
|
||||
# This configuration was generated by `rubocop --auto-gen-config`
|
||||
# on 2015-08-30 23:03:50 -0500 using RuboCop version 0.31.0.
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2015-08-31 04:23:33 -0500 using RuboCop version 0.33.0.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@ -8,67 +9,74 @@
|
||||
# Offense count: 1
|
||||
# Configuration parameters: AllowSafeAssignment.
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter/json_api.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/EmptyEnsure:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/serializers/adapter_for_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/HandleExceptions:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnusedBlockArgument:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter/json_api/fragment_cache.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnusedMethodArgument:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter.rb'
|
||||
- 'lib/active_model/serializer/adapter/null.rb'
|
||||
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
||||
- 'test/fixtures/poro.rb'
|
||||
- 'test/lint_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/UselessAccessModifier:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializable_resource.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Lint/UselessAssignment:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'bench/perf.rb'
|
||||
- 'lib/active_model/serializer/adapter/json_api/fragment_cache.rb'
|
||||
- 'test/test_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Rails/Date:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/fixtures/poro.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Rails/TimeZone:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/AccessModifierIndentation:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/action_controller/serialization_test.rb'
|
||||
- 'test/fixtures/poro.rb'
|
||||
- 'test/serializers/cache_test.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
|
||||
Style/AlignHash:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/AlignParameters:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/action_controller/json_api/pagination_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/AndOr:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/lint.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
@ -80,63 +88,51 @@ Style/BlockDelimiters:
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/BracesAroundHashParameters:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/action_controller/adapter_selector_test.rb'
|
||||
- 'test/action_controller/json_api/pagination_test.rb'
|
||||
- 'test/action_controller/serialization_test.rb'
|
||||
- 'test/adapter/json_api/linked_test.rb'
|
||||
- 'test/adapter/json_api/pagination_links_test.rb'
|
||||
- 'test/adapter/null_test.rb'
|
||||
- 'test/adapter_test.rb'
|
||||
- 'test/array_serializer_test.rb'
|
||||
- 'test/serializable_resource_test.rb'
|
||||
- 'test/serializers/associations_test.rb'
|
||||
- 'test/serializers/attribute_test.rb'
|
||||
- 'test/serializers/attributes_test.rb'
|
||||
- 'test/serializers/fieldset_test.rb'
|
||||
- 'test/serializers/root_test.rb'
|
||||
- 'test/serializers/urls_test.rb'
|
||||
|
||||
# Offense count: 167
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/ClassAndModuleChildren:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
Style/CommentIndentation:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'active_model_serializers.gemspec'
|
||||
|
||||
# Offense count: 1
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializable_resource.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/EachWithObject:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLines:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLinesAroundAccessModifier:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/EmptyLinesAroundBlockBody:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 16
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/EmptyLinesAroundClassBody:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLinesAroundMethodBody:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/EmptyLinesAroundModuleBody:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/fieldset.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer.rb'
|
||||
- 'lib/active_model/serializer/adapter/json_api.rb'
|
||||
- 'test/capture_warnings.rb'
|
||||
|
||||
# Offense count: 12
|
||||
# Cop supports --auto-correct.
|
||||
@ -147,7 +143,11 @@ Style/HashSyntax:
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
Style/IndentArray:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/adapter/json/has_many_test.rb'
|
||||
- 'test/adapter/json_api/json_api_test.rb'
|
||||
- 'test/adapter/json_api/pagination_links_test.rb'
|
||||
- 'test/adapter/json_test.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Cop supports --auto-correct.
|
||||
@ -159,23 +159,29 @@ Style/IndentHash:
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/IndentationConsistency:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/action_controller/serialization_scope_name_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Width.
|
||||
Style/IndentationWidth:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializable_resource.rb'
|
||||
- 'lib/active_model/serializer/fieldset.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/Lambda:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/MethodCallParentheses:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter/json.rb'
|
||||
- 'lib/active_model/serializer/adapter/json_api.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
@ -192,12 +198,14 @@ Style/MultilineOperationIndentation:
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/NegatedIf:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/action_controller/serialization.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
Style/Next:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter/json_api.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
@ -208,95 +216,56 @@ Style/NumericLiterals:
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: PreferredDelimiters.
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'active_model_serializers.gemspec'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/PerlBackrefs:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/fixtures/poro.rb'
|
||||
- 'test/serializers/associations_test.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
|
||||
Style/PredicateName:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/adapter.rb'
|
||||
- 'lib/active_model/serializer/adapter/json_api.rb'
|
||||
- 'lib/active_model/serializer/associations.rb'
|
||||
- 'test/action_controller/json_api/linked_test.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantSelf:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer.rb'
|
||||
- 'lib/active_model/serializer/associations.rb'
|
||||
- 'test/fixtures/poro.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowAsExpressionSeparator.
|
||||
Style/Semicolon:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/fieldset.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/SignalException:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer.rb'
|
||||
- 'lib/active_model/serializer/adapter.rb'
|
||||
- 'lib/active_model/serializer/fieldset.rb'
|
||||
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowIfMethodIsEmpty.
|
||||
Style/SingleLineMethods:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 26
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceAfterColon:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceAfterComma:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceAfterNot:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/SpaceAroundEqualsInParameterDefault:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 39
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: MultiSpaceAllowedForOperators.
|
||||
Style/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/SpaceBeforeBlockBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 8
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
||||
Style/SpaceInsideBlockBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 20
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceInsideBrackets:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 179
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
||||
Style/SpaceInsideHashLiteralBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceInsideParens:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/serializers/serializer_for_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
@ -306,42 +275,41 @@ Style/StringLiteralsInInterpolation:
|
||||
|
||||
# Offense count: 1
|
||||
Style/StructInheritance:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'bench/perf.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IgnoredMethods.
|
||||
Style/SymbolProc:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/generators/serializer/serializer_generator.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Offense count: 8
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/TrailingBlankLines:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
||||
- 'lib/generators/serializer/serializer_generator.rb'
|
||||
- 'test/adapter/fragment_cache_test.rb'
|
||||
- 'test/adapter/json_api/json_api_test.rb'
|
||||
- 'test/adapter/null_test.rb'
|
||||
- 'test/serializers/cache_test.rb'
|
||||
- 'test/serializers/fieldset_test.rb'
|
||||
- 'test/support/stream_capture.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
||||
Style/TrailingComma:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/TrailingWhitespace:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'test/action_controller/adapter_selector_test.rb'
|
||||
- 'test/action_controller/serialization_test.rb'
|
||||
- 'test/adapter/json_api/belongs_to_test.rb'
|
||||
- 'test/adapter/json_api/linked_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/UnlessElse:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnneededPercentQ:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: WordRegex.
|
||||
Style/WordArray:
|
||||
MinSize: 2
|
||||
Exclude:
|
||||
- 'lib/active_model/serializer.rb'
|
||||
|
||||
@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
||||
spec.platform = Gem::Platform::RUBY
|
||||
spec.authors = ['Steve Klabnik']
|
||||
spec.email = ['steve@steveklabnik.com']
|
||||
spec.summary = %q{Conventions-based JSON generation for Rails.}
|
||||
spec.description = %q{ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.}
|
||||
spec.summary = 'Conventions-based JSON generation for Rails.'
|
||||
spec.description = 'ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.'
|
||||
spec.homepage = 'https://github.com/rails-api/active_model_serializers'
|
||||
spec.license = 'MIT'
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
require 'set'
|
||||
module ActiveModel
|
||||
class SerializableResource
|
||||
|
||||
ADAPTER_OPTION_KEYS = Set.new([:include, :fields, :adapter])
|
||||
|
||||
def initialize(resource, options = {})
|
||||
@ -79,6 +78,5 @@ module ActiveModel
|
||||
ActiveModelSerializers.silence_warnings do
|
||||
attr_reader :resource, :adapter_opts, :serializer_opts
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -13,7 +13,6 @@ module ActiveModel
|
||||
include Configuration
|
||||
include Associations
|
||||
|
||||
|
||||
# Matches
|
||||
# "c:/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb:1:in `<top (required)>'"
|
||||
# AND
|
||||
|
||||
@ -2,7 +2,6 @@ module ActiveModel
|
||||
class Serializer
|
||||
class Adapter
|
||||
class FragmentCache
|
||||
|
||||
attr_reader :serializer
|
||||
|
||||
def initialize(adapter, serializer, options)
|
||||
|
||||
@ -46,7 +46,6 @@ module ActiveModel
|
||||
def fragment_cache(cached_hash, non_cached_hash)
|
||||
Json::FragmentCache.new().fragment_cache(cached_hash, non_cached_hash)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,11 +4,9 @@ module ActiveModel
|
||||
class Adapter
|
||||
class Json < Adapter
|
||||
class FragmentCache
|
||||
|
||||
def fragment_cache(cached_hash, non_cached_hash)
|
||||
non_cached_hash.merge cached_hash
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,7 +4,6 @@ module ActiveModel
|
||||
class Adapter
|
||||
class JsonApi < Adapter
|
||||
class FragmentCache
|
||||
|
||||
def fragment_cache(root, cached_hash, non_cached_hash)
|
||||
hash = {}
|
||||
core_cached = cached_hash.first
|
||||
@ -16,7 +15,6 @@ module ActiveModel
|
||||
|
||||
hash.deep_merge no_root_non_cache.deep_merge no_root_cache
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -10,7 +10,6 @@ module ActiveModel
|
||||
# Association.new(:comments, CommentSummarySerializer)
|
||||
#
|
||||
Association = Struct.new(:name, :serializer, :options) do
|
||||
|
||||
# @return [Symbol]
|
||||
#
|
||||
def key
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class Fieldset
|
||||
|
||||
def initialize(fields, root = nil)
|
||||
@root = root
|
||||
@raw_fields = fields
|
||||
@ -36,7 +35,6 @@ module ActiveModel
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,7 +15,6 @@ module ActiveModel::Serializer::Lint
|
||||
# always return +{}+, and the tests would pass. It is up to you to ensure
|
||||
# that the values are semantically meaningful.
|
||||
module Tests
|
||||
|
||||
# Passes if the object responds to <tt>serializable_hash</tt> and if it takes
|
||||
# zero or one arguments.
|
||||
# Fails otherwise.
|
||||
@ -126,6 +125,5 @@ module ActiveModel::Serializer::Lint
|
||||
def assert_instance_of(result, name)
|
||||
assert result.instance_of?(name), "#{result} should be an instance of #{name}"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,7 +8,6 @@ module ActiveModelSerializers
|
||||
ensure
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
require 'active_model'
|
||||
|
||||
@ -75,7 +75,7 @@ module ActionController
|
||||
|
||||
def render_collection_with_include
|
||||
setup_post
|
||||
render json: [@post], include: ['author', 'comments'], adapter: :json_api
|
||||
render json: [@post], include: %w(author comments), adapter: :json_api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -48,7 +48,6 @@ module ActionController
|
||||
|
||||
def render_array_using_implicit_serializer_and_meta
|
||||
with_adapter ActiveModel::Serializer::Adapter::JsonApi do
|
||||
|
||||
@profiles = [
|
||||
Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
]
|
||||
@ -138,6 +137,7 @@ module ActionController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_cached_serializer(obj)
|
||||
ActiveModel::SerializableResource.new(obj).to_json
|
||||
end
|
||||
|
||||
@ -108,7 +108,7 @@ module ActiveModel
|
||||
|
||||
def test_include_linked_resources_with_type_name
|
||||
serializer = BlogSerializer.new(@blog)
|
||||
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer, include: ['writer', 'articles'])
|
||||
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer, include: %w(writer articles))
|
||||
linked = adapter.serializable_hash[:included]
|
||||
expected = [
|
||||
{
|
||||
|
||||
@ -88,7 +88,6 @@ module ActiveModel
|
||||
]
|
||||
assert_equal(expected, @adapter.serializable_hash[:data])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,7 +24,7 @@ module ActiveModel
|
||||
@serializer = PostPreviewSerializer.new(@post)
|
||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(
|
||||
@serializer,
|
||||
include: ['comments', 'author']
|
||||
include: %w(comments author)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@ -16,7 +16,6 @@ module ActiveModel
|
||||
@post.author = @author
|
||||
@blog = Blog.new(id: 1, name: 'My Blog!!')
|
||||
@post.blog = @blog
|
||||
|
||||
end
|
||||
|
||||
def test_custom_keys
|
||||
|
||||
@ -53,5 +53,6 @@ class CaptureWarnings
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :stderr_file, :app_root, :output_dir, :bundle_dir, :fail_on_warnings
|
||||
end
|
||||
|
||||
@ -7,27 +7,21 @@ module ActiveModel
|
||||
|
||||
class CompliantResource
|
||||
def serializable_hash(options = nil)
|
||||
|
||||
end
|
||||
|
||||
def read_attribute_for_serialization(name)
|
||||
|
||||
end
|
||||
|
||||
def as_json(options = nil)
|
||||
|
||||
end
|
||||
|
||||
def to_json(options = nil)
|
||||
|
||||
end
|
||||
|
||||
def cache_key
|
||||
|
||||
end
|
||||
|
||||
def id
|
||||
|
||||
end
|
||||
|
||||
def self.model_name
|
||||
@ -38,7 +32,6 @@ module ActiveModel
|
||||
def setup
|
||||
@resource = CompliantResource.new
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,7 +20,6 @@ module ActiveModel
|
||||
adapter = ActiveModel::Serializer.adapter
|
||||
assert_equal ActiveModel::Serializer::Adapter::Null, adapter
|
||||
ensure
|
||||
|
||||
end
|
||||
|
||||
def test_overwrite_adapter_with_class
|
||||
|
||||
@ -26,7 +26,6 @@ module ActiveModel
|
||||
def test_required_fields
|
||||
assert_equal({ name: 'Name 1', description: 'Description 1' },
|
||||
@profile_serializer.attributes(fields: [:name, :description], required_fields: [:name]))
|
||||
|
||||
end
|
||||
|
||||
def test_attributes_inheritance_definition
|
||||
|
||||
@ -155,6 +155,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_object_with_cache(obj)
|
||||
ActiveModel::SerializableResource.new(obj).serializable_hash
|
||||
end
|
||||
|
||||
@ -3,9 +3,8 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class FieldsetTest < Minitest::Test
|
||||
|
||||
def test_fieldset_with_hash
|
||||
fieldset = ActiveModel::Serializer::Fieldset.new({'post' => ['id', 'title'], 'coment' => ['body']})
|
||||
fieldset = ActiveModel::Serializer::Fieldset.new({ 'post' => %w(id title), 'coment' => ['body'] })
|
||||
|
||||
assert_equal(
|
||||
{ :post => [:id, :title], :coment => [:body] },
|
||||
|
||||
@ -3,7 +3,6 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class RootTest < Minitest::Test
|
||||
|
||||
def setup
|
||||
@virtual_value = VirtualValue.new(id: 1)
|
||||
end
|
||||
@ -17,7 +16,6 @@ module ActiveModel
|
||||
serializer = VirtualValueSerializer.new(@virtual_value)
|
||||
assert_equal('virtual_value', serializer.json_key)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,7 +3,6 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class UrlsTest < Minitest::Test
|
||||
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@post = Post.new({ title: 'New Post', body: 'Body' })
|
||||
|
||||
@ -13,7 +13,6 @@ require 'minitest/autorun'
|
||||
# Ensure backward compatibility with Minitest 4
|
||||
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
||||
|
||||
|
||||
require 'capture_warnings'
|
||||
@capture_warnings = CaptureWarnings.new(fail_build = true)
|
||||
@capture_warnings.before_tests
|
||||
|
||||
Loading…
Reference in New Issue
Block a user