mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Use Minitest::Test instead of ActiveModel::TestCase
This commit is contained in:
parent
cec7980208
commit
1ec499bd64
2
Gemfile
2
Gemfile
@ -22,4 +22,4 @@ platforms :rbx do
|
||||
gem 'racc', '~> 1.4.10'
|
||||
end
|
||||
|
||||
gem 'rails', "~> 4.0.0"
|
||||
gem 'rails', '~> 4.0.0'
|
||||
|
||||
@ -3,7 +3,7 @@ require 'fixtures/active_record'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class ActiveRecordTest < ActiveModel::TestCase
|
||||
class ActiveRecordTest < Minitest::Test
|
||||
def setup
|
||||
@post = ARPost.first
|
||||
end
|
||||
|
||||
@ -16,7 +16,6 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
||||
run_generator
|
||||
|
||||
assert_file 'app/controllers/accounts_controller.rb' do |content|
|
||||
|
||||
assert_instance_method :index, content do |m|
|
||||
assert_match /@accounts = Account\.all/, m
|
||||
assert_match /format.html/, m
|
||||
@ -60,8 +59,6 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
assert_match(/def account_params/, content)
|
||||
assert_match(/params\.require\(:account\)\.permit\(:name, :description, :business_id\)/, content)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,6 +4,9 @@ require 'minitest/autorun'
|
||||
require 'active_model_serializers'
|
||||
require 'fixtures/poro'
|
||||
|
||||
# Ensure backward compatibility with Minitest 4
|
||||
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
||||
|
||||
module TestHelper
|
||||
Routes = ActionDispatch::Routing::RouteSet.new
|
||||
Routes.draw do
|
||||
|
||||
@ -3,7 +3,7 @@ require 'active_model/serializer'
|
||||
|
||||
module ActiveModel
|
||||
class ArraySerializer
|
||||
class MetaTest < ActiveModel::TestCase
|
||||
class MetaTest < Minitest::Test
|
||||
def setup
|
||||
@profile1 = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile2 = Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class ArraySerializer
|
||||
class RootAsOptionTest < ActiveModel::TestCase
|
||||
class RootAsOptionTest < Minitest::Test
|
||||
def setup
|
||||
@old_root = ArraySerializer._root
|
||||
@profile1 = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@ -50,7 +50,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class RootInSerializerTest < ActiveModel::TestCase
|
||||
class RootInSerializerTest < Minitest::Test
|
||||
def setup
|
||||
@old_root = ArraySerializer._root
|
||||
ArraySerializer._root = :in_serializer
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class ArraySerializer
|
||||
class ScopeTest < ActiveModel::TestCase
|
||||
class ScopeTest < Minitest::Test
|
||||
def test_array_serializer_pass_options_to_items_serializers
|
||||
array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
|
||||
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })]
|
||||
|
||||
@ -2,10 +2,10 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class ArraySerializer
|
||||
class BasicObjectsSerializationTest < ActiveModel::TestCase
|
||||
class BasicObjectsSerializationTest < Minitest::Test
|
||||
def setup
|
||||
array = [1, 2, 3]
|
||||
@serializer = ActiveModel::Serializer.serializer_for(array).new(array)
|
||||
@serializer = Serializer.serializer_for(array).new(array)
|
||||
end
|
||||
|
||||
def test_serializer_for_array_returns_appropriate_type
|
||||
@ -18,7 +18,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class ModelSerializationTest < ActiveModel::TestCase
|
||||
class ModelSerializationTest < Minitest::Test
|
||||
def test_array_serializer_serializes_models
|
||||
array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
|
||||
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })]
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class DefaultSerializer
|
||||
class Test < ActiveModel::TestCase
|
||||
class Test < Minitest::Test
|
||||
def test_serialize_objects
|
||||
assert_equal(nil, DefaultSerializer.new(nil).serializable_object)
|
||||
assert_equal(1, DefaultSerializer.new(1).serializable_object)
|
||||
|
||||
@ -3,7 +3,7 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class Association
|
||||
class BuildSerializerTest < ActiveModel::TestCase
|
||||
class BuildSerializerTest < Minitest::Test
|
||||
def setup
|
||||
@association = Association::HasOne.new('post', serializer: PostSerializer)
|
||||
@post = Post.new({ title: 'Title 1', body: 'Body 1', date: '1/1/2000' })
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class AssociationsTest < ActiveModel::TestCase
|
||||
class AssociationsTest < Minitest::Test
|
||||
def test_associations_inheritance
|
||||
inherited_serializer_klass = Class.new(PostSerializer) do
|
||||
has_many :users
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class AttributesTest < ActiveModel::TestCase
|
||||
class AttributesTest < Minitest::Test
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile_serializer = ProfileSerializer.new(@profile)
|
||||
|
||||
@ -3,7 +3,7 @@ require 'test_helper'
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class Config
|
||||
class Test < ActiveModel::TestCase
|
||||
class Test < Minitest::Test
|
||||
def test_config_const_is_an_instance_of_config
|
||||
assert_kind_of Config, CONFIG
|
||||
end
|
||||
@ -30,9 +30,9 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class ConfigTest < ActiveModel::TestCase
|
||||
class ConfigTest < Minitest::Test
|
||||
def test_setup
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
Serializer.setup do |config|
|
||||
config.a = 'v1'
|
||||
config.b = 'v2'
|
||||
end
|
||||
@ -44,7 +44,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_config_accessors
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
Serializer.setup do |config|
|
||||
config.foo = 'v1'
|
||||
config.bar = 'v2'
|
||||
end
|
||||
@ -63,7 +63,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class ApplyConfigTest < ActiveModel::TestCase
|
||||
class ApplyConfigTest < Minitest::Test
|
||||
def test_apply_config_to_associations
|
||||
CONFIG.embed = :ids
|
||||
CONFIG.embed_in_root = true
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class FilterAttributesTest < ActiveModel::TestCase
|
||||
class FilterAttributesTest < Minitest::Test
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile_serializer = ProfileSerializer.new(@profile)
|
||||
@ -20,7 +20,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class FilterAssociationsTest < ActiveModel::TestCase
|
||||
class FilterAssociationsTest < Minitest::Test
|
||||
def setup
|
||||
@association = PostSerializer._associations[:comments]
|
||||
@old_association = @association.dup
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class HasManyTest < ActiveModel::TestCase
|
||||
class HasManyTest < Minitest::Test
|
||||
def setup
|
||||
@association = PostSerializer._associations[:comments]
|
||||
@old_association = @association.dup
|
||||
@ -128,7 +128,7 @@ module ActiveModel
|
||||
def test_associations_using_a_given_serializer
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
|
||||
@association.serializer_from_options = Class.new(Serializer) do
|
||||
def content
|
||||
object.read_attribute_for_serialization(:content) + '!'
|
||||
end
|
||||
@ -145,7 +145,7 @@ module ActiveModel
|
||||
def test_associations_embedding_ids_using_a_given_array_serializer
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.serializer_from_options = Class.new(ActiveModel::ArraySerializer) do
|
||||
@association.serializer_from_options = Class.new(ArraySerializer) do
|
||||
def serializable_object
|
||||
{ my_content: ['fake'] }
|
||||
end
|
||||
@ -158,7 +158,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_associations_embedding_objects_using_a_given_array_serializer
|
||||
@association.serializer_from_options = Class.new(ActiveModel::ArraySerializer) do
|
||||
@association.serializer_from_options = Class.new(ArraySerializer) do
|
||||
def serializable_object
|
||||
{ my_content: ['fake'] }
|
||||
end
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class HasOneTest < ActiveModel::TestCase
|
||||
class HasOneTest < Minitest::Test
|
||||
def setup
|
||||
@association = UserSerializer._associations[:profile]
|
||||
@old_association = @association.dup
|
||||
@ -119,7 +119,7 @@ module ActiveModel
|
||||
def test_associations_embedding_ids_using_a_given_serializer
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
|
||||
@association.serializer_from_options = Class.new(Serializer) do
|
||||
def name
|
||||
'fake'
|
||||
end
|
||||
@ -134,7 +134,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_associations_embedding_objects_using_a_given_serializer
|
||||
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
|
||||
@association.serializer_from_options = Class.new(Serializer) do
|
||||
def name
|
||||
'fake'
|
||||
end
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class MetaTest < ActiveModel::TestCase
|
||||
class MetaTest < Minitest::Test
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
end
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class RootAsOptionTest < ActiveModel::TestCase
|
||||
class RootAsOptionTest < Minitest::Test
|
||||
def setup
|
||||
@old_root = ProfileSerializer._root
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@ -70,7 +70,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class RootInSerializerTest < ActiveModel::TestCase
|
||||
class RootInSerializerTest < Minitest::Test
|
||||
def setup
|
||||
@old_root = ProfileSerializer._root
|
||||
ProfileSerializer._root = :in_serializer
|
||||
|
||||
@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class ScopeTest < ActiveModel::TestCase
|
||||
class ScopeTest < Minitest::Test
|
||||
def setup
|
||||
@serializer = ProfileSerializer.new(nil, scope: current_user)
|
||||
end
|
||||
@ -18,7 +18,7 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class NestedScopeTest < ActiveModel::TestCase
|
||||
class NestedScopeTest < Minitest::Test
|
||||
def setup
|
||||
@association = UserSerializer._associations[:profile]
|
||||
@old_association = @association.dup
|
||||
@ -31,7 +31,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_scope_passed_through
|
||||
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
|
||||
@association.serializer_from_options = Class.new(Serializer) do
|
||||
def name
|
||||
scope
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user