Skip to content

Commit 1ec499b

Browse files
committed
Use Minitest::Test instead of ActiveModel::TestCase
1 parent cec7980 commit 1ec499b

19 files changed

+36
-36
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ platforms :rbx do
2222
gem 'racc', '~> 1.4.10'
2323
end
2424

25-
gem 'rails', "~> 4.0.0"
25+
gem 'rails', '~> 4.0.0'

test/integration/active_record/active_record_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module ActiveModel
55
class Serializer
6-
class ActiveRecordTest < ActiveModel::TestCase
6+
class ActiveRecordTest < Minitest::Test
77
def setup
88
@post = ARPost.first
99
end

test/integration/generators/scaffold_controller_generator_test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def test_generated_controller
1616
run_generator
1717

1818
assert_file 'app/controllers/accounts_controller.rb' do |content|
19-
2019
assert_instance_method :index, content do |m|
2120
assert_match /@accounts = Account\.all/, m
2221
assert_match /format.html/, m
@@ -60,8 +59,6 @@ def test_generated_controller
6059

6160
assert_match(/def account_params/, content)
6261
assert_match(/params\.require\(:account\)\.permit\(:name, :description, :business_id\)/, content)
63-
6462
end
65-
6663
end
6764
end

test/test_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
require 'active_model_serializers'
55
require 'fixtures/poro'
66

7+
# Ensure backward compatibility with Minitest 4
8+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
9+
710
module TestHelper
811
Routes = ActionDispatch::Routing::RouteSet.new
912
Routes.draw do

test/unit/active_model/array_serializer/meta_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module ActiveModel
55
class ArraySerializer
6-
class MetaTest < ActiveModel::TestCase
6+
class MetaTest < Minitest::Test
77
def setup
88
@profile1 = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
99
@profile2 = Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })

test/unit/active_model/array_serializer/root_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class ArraySerializer
5-
class RootAsOptionTest < ActiveModel::TestCase
5+
class RootAsOptionTest < Minitest::Test
66
def setup
77
@old_root = ArraySerializer._root
88
@profile1 = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@@ -50,7 +50,7 @@ def test_using_false_root_in_initialize_takes_precedence
5050
end
5151
end
5252

53-
class RootInSerializerTest < ActiveModel::TestCase
53+
class RootInSerializerTest < Minitest::Test
5454
def setup
5555
@old_root = ArraySerializer._root
5656
ArraySerializer._root = :in_serializer

test/unit/active_model/array_serializer/scope_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class ArraySerializer
5-
class ScopeTest < ActiveModel::TestCase
5+
class ScopeTest < Minitest::Test
66
def test_array_serializer_pass_options_to_items_serializers
77
array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
88
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })]

test/unit/active_model/array_serializer/serialization_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
module ActiveModel
44
class ArraySerializer
5-
class BasicObjectsSerializationTest < ActiveModel::TestCase
5+
class BasicObjectsSerializationTest < Minitest::Test
66
def setup
77
array = [1, 2, 3]
8-
@serializer = ActiveModel::Serializer.serializer_for(array).new(array)
8+
@serializer = Serializer.serializer_for(array).new(array)
99
end
1010

1111
def test_serializer_for_array_returns_appropriate_type
@@ -18,7 +18,7 @@ def test_array_serializer_serializes_simple_objects
1818
end
1919
end
2020

21-
class ModelSerializationTest < ActiveModel::TestCase
21+
class ModelSerializationTest < Minitest::Test
2222
def test_array_serializer_serializes_models
2323
array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
2424
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })]

test/unit/active_model/default_serializer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class DefaultSerializer
5-
class Test < ActiveModel::TestCase
5+
class Test < Minitest::Test
66
def test_serialize_objects
77
assert_equal(nil, DefaultSerializer.new(nil).serializable_object)
88
assert_equal(1, DefaultSerializer.new(1).serializable_object)

test/unit/active_model/serializer/associations/build_serializer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module ActiveModel
44
class Serializer
55
class Association
6-
class BuildSerializerTest < ActiveModel::TestCase
6+
class BuildSerializerTest < Minitest::Test
77
def setup
88
@association = Association::HasOne.new('post', serializer: PostSerializer)
99
@post = Post.new({ title: 'Title 1', body: 'Body 1', date: '1/1/2000' })

test/unit/active_model/serializer/associations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class AssociationsTest < ActiveModel::TestCase
5+
class AssociationsTest < Minitest::Test
66
def test_associations_inheritance
77
inherited_serializer_klass = Class.new(PostSerializer) do
88
has_many :users

test/unit/active_model/serializer/attributes_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class AttributesTest < ActiveModel::TestCase
5+
class AttributesTest < Minitest::Test
66
def setup
77
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
88
@profile_serializer = ProfileSerializer.new(@profile)

test/unit/active_model/serializer/config_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module ActiveModel
44
class Serializer
55
class Config
6-
class Test < ActiveModel::TestCase
6+
class Test < Minitest::Test
77
def test_config_const_is_an_instance_of_config
88
assert_kind_of Config, CONFIG
99
end
@@ -30,9 +30,9 @@ def test_each_config
3030
end
3131
end
3232

33-
class ConfigTest < ActiveModel::TestCase
33+
class ConfigTest < Minitest::Test
3434
def test_setup
35-
ActiveModel::Serializer.setup do |config|
35+
Serializer.setup do |config|
3636
config.a = 'v1'
3737
config.b = 'v2'
3838
end
@@ -44,7 +44,7 @@ def test_setup
4444
end
4545

4646
def test_config_accessors
47-
ActiveModel::Serializer.setup do |config|
47+
Serializer.setup do |config|
4848
config.foo = 'v1'
4949
config.bar = 'v2'
5050
end
@@ -63,7 +63,7 @@ def test_acessor_when_nil
6363
end
6464
end
6565

66-
class ApplyConfigTest < ActiveModel::TestCase
66+
class ApplyConfigTest < Minitest::Test
6767
def test_apply_config_to_associations
6868
CONFIG.embed = :ids
6969
CONFIG.embed_in_root = true

test/unit/active_model/serializer/filter_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class FilterAttributesTest < ActiveModel::TestCase
5+
class FilterAttributesTest < Minitest::Test
66
def setup
77
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
88
@profile_serializer = ProfileSerializer.new(@profile)
@@ -20,7 +20,7 @@ def test_filtered_attributes_serialization
2020
end
2121
end
2222

23-
class FilterAssociationsTest < ActiveModel::TestCase
23+
class FilterAssociationsTest < Minitest::Test
2424
def setup
2525
@association = PostSerializer._associations[:comments]
2626
@old_association = @association.dup

test/unit/active_model/serializer/has_many_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class HasManyTest < ActiveModel::TestCase
5+
class HasManyTest < Minitest::Test
66
def setup
77
@association = PostSerializer._associations[:comments]
88
@old_association = @association.dup
@@ -128,7 +128,7 @@ def test_associations_embedding_nothing_including_objects_serialization_using_as
128128
def test_associations_using_a_given_serializer
129129
@association.embed = :ids
130130
@association.embed_in_root = true
131-
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
131+
@association.serializer_from_options = Class.new(Serializer) do
132132
def content
133133
object.read_attribute_for_serialization(:content) + '!'
134134
end
@@ -145,7 +145,7 @@ def content
145145
def test_associations_embedding_ids_using_a_given_array_serializer
146146
@association.embed = :ids
147147
@association.embed_in_root = true
148-
@association.serializer_from_options = Class.new(ActiveModel::ArraySerializer) do
148+
@association.serializer_from_options = Class.new(ArraySerializer) do
149149
def serializable_object
150150
{ my_content: ['fake'] }
151151
end
@@ -158,7 +158,7 @@ def serializable_object
158158
end
159159

160160
def test_associations_embedding_objects_using_a_given_array_serializer
161-
@association.serializer_from_options = Class.new(ActiveModel::ArraySerializer) do
161+
@association.serializer_from_options = Class.new(ArraySerializer) do
162162
def serializable_object
163163
{ my_content: ['fake'] }
164164
end

test/unit/active_model/serializer/has_one_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class HasOneTest < ActiveModel::TestCase
5+
class HasOneTest < Minitest::Test
66
def setup
77
@association = UserSerializer._associations[:profile]
88
@old_association = @association.dup
@@ -119,7 +119,7 @@ def test_associations_embedding_ids_including_objects_serialization_using_as_jso
119119
def test_associations_embedding_ids_using_a_given_serializer
120120
@association.embed = :ids
121121
@association.embed_in_root = true
122-
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
122+
@association.serializer_from_options = Class.new(Serializer) do
123123
def name
124124
'fake'
125125
end
@@ -134,7 +134,7 @@ def name
134134
end
135135

136136
def test_associations_embedding_objects_using_a_given_serializer
137-
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
137+
@association.serializer_from_options = Class.new(Serializer) do
138138
def name
139139
'fake'
140140
end

test/unit/active_model/serializer/meta_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class MetaTest < ActiveModel::TestCase
5+
class MetaTest < Minitest::Test
66
def setup
77
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
88
end

test/unit/active_model/serializer/root_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class RootAsOptionTest < ActiveModel::TestCase
5+
class RootAsOptionTest < Minitest::Test
66
def setup
77
@old_root = ProfileSerializer._root
88
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@@ -70,7 +70,7 @@ def test_root_inheritance
7070
end
7171
end
7272

73-
class RootInSerializerTest < ActiveModel::TestCase
73+
class RootInSerializerTest < Minitest::Test
7474
def setup
7575
@old_root = ProfileSerializer._root
7676
ProfileSerializer._root = :in_serializer

test/unit/active_model/serializer/scope_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveModel
44
class Serializer
5-
class ScopeTest < ActiveModel::TestCase
5+
class ScopeTest < Minitest::Test
66
def setup
77
@serializer = ProfileSerializer.new(nil, scope: current_user)
88
end
@@ -18,7 +18,7 @@ def current_user
1818
end
1919
end
2020

21-
class NestedScopeTest < ActiveModel::TestCase
21+
class NestedScopeTest < Minitest::Test
2222
def setup
2323
@association = UserSerializer._associations[:profile]
2424
@old_association = @association.dup
@@ -31,7 +31,7 @@ def teardown
3131
end
3232

3333
def test_scope_passed_through
34-
@association.serializer_from_options = Class.new(ActiveModel::Serializer) do
34+
@association.serializer_from_options = Class.new(Serializer) do
3535
def name
3636
scope
3737
end

0 commit comments

Comments
 (0)