active_model_serializers 0.10.0 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +10 -5
- data/.travis.yml +41 -21
- data/CHANGELOG.md +200 -2
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +25 -4
- data/README.md +166 -28
- data/Rakefile +5 -32
- data/active_model_serializers.gemspec +23 -25
- data/appveyor.yml +10 -6
- data/bin/rubocop +38 -0
- data/docs/README.md +2 -1
- data/docs/general/adapters.md +35 -11
- data/docs/general/caching.md +7 -1
- data/docs/general/configuration_options.md +86 -1
- data/docs/general/deserialization.md +1 -1
- data/docs/general/fields.md +31 -0
- data/docs/general/getting_started.md +1 -1
- data/docs/general/logging.md +7 -0
- data/docs/general/rendering.md +63 -25
- data/docs/general/serializers.md +137 -14
- data/docs/howto/add_pagination_links.md +16 -17
- data/docs/howto/add_relationship_links.md +140 -0
- data/docs/howto/add_root_key.md +11 -0
- data/docs/howto/grape_integration.md +42 -0
- data/docs/howto/outside_controller_use.md +12 -4
- data/docs/howto/passing_arbitrary_options.md +2 -2
- data/docs/howto/serialize_poro.md +46 -5
- data/docs/howto/test.md +2 -0
- data/docs/howto/upgrade_from_0_8_to_0_10.md +265 -0
- data/docs/integrations/ember-and-json-api.md +67 -32
- data/docs/jsonapi/schema.md +1 -1
- data/lib/action_controller/serialization.rb +15 -3
- data/lib/active_model/serializable_resource.rb +2 -0
- data/lib/active_model/serializer/adapter/attributes.rb +2 -0
- data/lib/active_model/serializer/adapter/base.rb +4 -0
- data/lib/active_model/serializer/adapter/json.rb +2 -0
- data/lib/active_model/serializer/adapter/json_api.rb +2 -0
- data/lib/active_model/serializer/adapter/null.rb +2 -0
- data/lib/active_model/serializer/adapter.rb +2 -0
- data/lib/active_model/serializer/array_serializer.rb +10 -5
- data/lib/active_model/serializer/association.rb +64 -10
- data/lib/active_model/serializer/attribute.rb +2 -0
- data/lib/active_model/serializer/belongs_to_reflection.rb +6 -3
- data/lib/active_model/serializer/collection_serializer.rb +39 -13
- data/lib/active_model/serializer/{caching.rb → concerns/caching.rb} +87 -116
- data/lib/active_model/serializer/error_serializer.rb +13 -7
- data/lib/active_model/serializer/errors_serializer.rb +27 -20
- data/lib/active_model/serializer/field.rb +2 -0
- data/lib/active_model/serializer/fieldset.rb +2 -0
- data/lib/active_model/serializer/has_many_reflection.rb +5 -3
- data/lib/active_model/serializer/has_one_reflection.rb +3 -4
- data/lib/active_model/serializer/lazy_association.rb +99 -0
- data/lib/active_model/serializer/link.rb +23 -0
- data/lib/active_model/serializer/lint.rb +136 -130
- data/lib/active_model/serializer/null.rb +2 -0
- data/lib/active_model/serializer/reflection.rb +132 -67
- data/lib/active_model/serializer/version.rb +3 -1
- data/lib/active_model/serializer.rb +308 -82
- data/lib/active_model_serializers/adapter/attributes.rb +5 -66
- data/lib/active_model_serializers/adapter/base.rb +41 -39
- data/lib/active_model_serializers/adapter/json.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/deserialization.rb +4 -2
- data/lib/active_model_serializers/adapter/json_api/error.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/link.rb +3 -1
- data/lib/active_model_serializers/adapter/json_api/meta.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +49 -21
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +77 -23
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +41 -10
- data/lib/active_model_serializers/adapter/json_api.rb +84 -65
- data/lib/active_model_serializers/adapter/null.rb +2 -0
- data/lib/active_model_serializers/adapter.rb +9 -1
- data/lib/active_model_serializers/callbacks.rb +2 -0
- data/lib/active_model_serializers/deprecate.rb +3 -2
- data/lib/active_model_serializers/deserialization.rb +4 -0
- data/lib/active_model_serializers/json_pointer.rb +2 -0
- data/lib/active_model_serializers/logging.rb +2 -0
- data/lib/active_model_serializers/lookup_chain.rb +82 -0
- data/lib/active_model_serializers/model.rb +111 -28
- data/lib/active_model_serializers/railtie.rb +7 -1
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +46 -31
- data/lib/active_model_serializers/serializable_resource.rb +10 -7
- data/lib/active_model_serializers/serialization_context.rb +12 -3
- data/lib/active_model_serializers/test/schema.rb +4 -2
- data/lib/active_model_serializers/test/serializer.rb +2 -0
- data/lib/active_model_serializers/test.rb +2 -0
- data/lib/active_model_serializers.rb +35 -10
- data/lib/generators/rails/resource_override.rb +3 -1
- data/lib/generators/rails/serializer_generator.rb +6 -4
- data/lib/grape/active_model_serializers.rb +9 -5
- data/lib/grape/formatters/active_model_serializers.rb +21 -2
- data/lib/grape/helpers/active_model_serializers.rb +3 -0
- data/lib/tasks/rubocop.rake +55 -0
- data/test/action_controller/adapter_selector_test.rb +16 -5
- data/test/action_controller/explicit_serializer_test.rb +7 -4
- data/test/action_controller/json/include_test.rb +108 -27
- data/test/action_controller/json_api/deserialization_test.rb +3 -1
- data/test/action_controller/json_api/errors_test.rb +10 -9
- data/test/action_controller/json_api/fields_test.rb +68 -0
- data/test/action_controller/json_api/linked_test.rb +31 -24
- data/test/action_controller/json_api/pagination_test.rb +33 -23
- data/test/action_controller/json_api/transform_test.rb +13 -3
- data/test/action_controller/lookup_proc_test.rb +51 -0
- data/test/action_controller/namespace_lookup_test.rb +234 -0
- data/test/action_controller/serialization_scope_name_test.rb +14 -6
- data/test/action_controller/serialization_test.rb +23 -12
- data/test/active_model_serializers/adapter_for_test.rb +2 -0
- data/test/active_model_serializers/json_pointer_test.rb +17 -13
- data/test/active_model_serializers/logging_test.rb +2 -0
- data/test/active_model_serializers/model_test.rb +139 -4
- data/test/active_model_serializers/railtie_test_isolated.rb +14 -7
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +163 -0
- data/test/active_model_serializers/serialization_context_test_isolated.rb +25 -10
- data/test/active_model_serializers/test/schema_test.rb +5 -2
- data/test/active_model_serializers/test/serializer_test.rb +2 -0
- data/test/active_record_test.rb +2 -0
- data/test/adapter/attributes_test.rb +42 -0
- data/test/adapter/deprecation_test.rb +2 -0
- data/test/adapter/json/belongs_to_test.rb +2 -0
- data/test/adapter/json/collection_test.rb +16 -0
- data/test/adapter/json/has_many_test.rb +12 -2
- data/test/adapter/json/transform_test.rb +17 -15
- data/test/adapter/json_api/belongs_to_test.rb +2 -0
- data/test/adapter/json_api/collection_test.rb +6 -3
- data/test/adapter/json_api/errors_test.rb +19 -19
- data/test/adapter/json_api/fields_test.rb +14 -3
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +2 -0
- data/test/adapter/json_api/has_many_test.rb +51 -20
- data/test/adapter/json_api/has_one_test.rb +2 -0
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +215 -0
- data/test/adapter/json_api/json_api_test.rb +7 -7
- data/test/adapter/json_api/linked_test.rb +35 -12
- data/test/adapter/json_api/links_test.rb +22 -3
- data/test/adapter/json_api/pagination_links_test.rb +55 -13
- data/test/adapter/json_api/parse_test.rb +3 -1
- data/test/adapter/json_api/relationship_test.rb +311 -73
- data/test/adapter/json_api/resource_meta_test.rb +5 -3
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +2 -0
- data/test/adapter/json_api/transform_test.rb +265 -253
- data/test/adapter/json_api/type_test.rb +170 -36
- data/test/adapter/json_test.rb +10 -7
- data/test/adapter/null_test.rb +3 -2
- data/test/adapter/polymorphic_test.rb +54 -5
- data/test/adapter_test.rb +3 -1
- data/test/array_serializer_test.rb +2 -0
- data/test/benchmark/app.rb +3 -1
- data/test/benchmark/benchmarking_support.rb +3 -1
- data/test/benchmark/bm_active_record.rb +83 -0
- data/test/benchmark/bm_adapter.rb +40 -0
- data/test/benchmark/bm_caching.rb +18 -16
- data/test/benchmark/bm_lookup_chain.rb +85 -0
- data/test/benchmark/bm_transform.rb +23 -10
- data/test/benchmark/controllers.rb +18 -17
- data/test/benchmark/fixtures.rb +74 -72
- data/test/cache_test.rb +301 -69
- data/test/collection_serializer_test.rb +33 -14
- data/test/fixtures/active_record.rb +47 -10
- data/test/fixtures/poro.rb +128 -183
- data/test/generators/scaffold_controller_generator_test.rb +2 -0
- data/test/generators/serializer_generator_test.rb +25 -5
- data/test/grape_test.rb +172 -56
- data/test/lint_test.rb +3 -1
- data/test/logger_test.rb +15 -11
- data/test/poro_test.rb +2 -0
- data/test/serializable_resource_test.rb +20 -22
- data/test/serializers/association_macros_test.rb +5 -2
- data/test/serializers/associations_test.rb +274 -49
- data/test/serializers/attribute_test.rb +7 -3
- data/test/serializers/attributes_test.rb +3 -1
- data/test/serializers/caching_configuration_test_isolated.rb +8 -6
- data/test/serializers/configuration_test.rb +2 -0
- data/test/serializers/fieldset_test.rb +3 -1
- data/test/serializers/meta_test.rb +14 -6
- data/test/serializers/options_test.rb +19 -6
- data/test/serializers/read_attribute_for_serialization_test.rb +5 -3
- data/test/serializers/reflection_test.rb +481 -0
- data/test/serializers/root_test.rb +3 -1
- data/test/serializers/serialization_test.rb +4 -2
- data/test/serializers/serializer_for_test.rb +14 -10
- data/test/serializers/serializer_for_with_namespace_test.rb +90 -0
- data/test/support/isolated_unit.rb +11 -4
- data/test/support/rails5_shims.rb +10 -2
- data/test/support/rails_app.rb +4 -9
- data/test/support/serialization_testing.rb +33 -5
- data/test/test_helper.rb +15 -0
- metadata +126 -46
- data/.rubocop_todo.yml +0 -167
- data/docs/ARCHITECTURE.md +0 -126
- data/lib/active_model/serializer/associations.rb +0 -100
- data/lib/active_model/serializer/attributes.rb +0 -82
- data/lib/active_model/serializer/collection_reflection.rb +0 -7
- data/lib/active_model/serializer/configuration.rb +0 -35
- data/lib/active_model/serializer/include_tree.rb +0 -111
- data/lib/active_model/serializer/links.rb +0 -35
- data/lib/active_model/serializer/meta.rb +0 -29
- data/lib/active_model/serializer/singular_reflection.rb +0 -7
- data/lib/active_model/serializer/type.rb +0 -25
- data/lib/active_model_serializers/key_transform.rb +0 -70
- data/test/active_model_serializers/key_transform_test.rb +0 -263
- data/test/adapter/json_api/has_many_embed_ids_test.rb +0 -43
- data/test/adapter/json_api/relationships_test.rb +0 -199
- data/test/adapter/json_api/resource_identifier_test.rb +0 -85
- data/test/include_tree/from_include_args_test.rb +0 -26
- data/test/include_tree/from_string_test.rb +0 -94
- data/test/include_tree/include_args_to_hash_test.rb +0 -64
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module ActiveModel
|
6
|
+
class Serializer
|
7
|
+
class SerializerForWithNamespaceTest < ActiveSupport::TestCase
|
8
|
+
class Book < ::Model
|
9
|
+
attributes :title, :author_name
|
10
|
+
associations :publisher, :pages
|
11
|
+
end
|
12
|
+
class Page < ::Model; attributes :number, :text end
|
13
|
+
class Publisher < ::Model; attributes :name end
|
14
|
+
|
15
|
+
module Api
|
16
|
+
module V3
|
17
|
+
class BookSerializer < ActiveModel::Serializer
|
18
|
+
attributes :title, :author_name
|
19
|
+
|
20
|
+
has_many :pages
|
21
|
+
belongs_to :publisher
|
22
|
+
end
|
23
|
+
|
24
|
+
class PageSerializer < ActiveModel::Serializer
|
25
|
+
attributes :number, :text
|
26
|
+
end
|
27
|
+
|
28
|
+
class PublisherSerializer < ActiveModel::Serializer
|
29
|
+
attributes :name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class BookSerializer < ActiveModel::Serializer
|
35
|
+
attributes :title, :author_name
|
36
|
+
end
|
37
|
+
test 'resource without a namespace' do
|
38
|
+
book = Book.new(title: 'A Post', author_name: 'hello')
|
39
|
+
|
40
|
+
# TODO: this should be able to pull up this serializer without explicitly specifying the serializer
|
41
|
+
# currently, with no options, it still uses the Api::V3 serializer
|
42
|
+
result = ActiveModelSerializers::SerializableResource.new(book, serializer: BookSerializer).serializable_hash
|
43
|
+
|
44
|
+
expected = { title: 'A Post', author_name: 'hello' }
|
45
|
+
assert_equal expected, result
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'resource with namespace' do
|
49
|
+
book = Book.new(title: 'A Post', author_name: 'hi')
|
50
|
+
|
51
|
+
result = ActiveModelSerializers::SerializableResource.new(book, namespace: Api::V3).serializable_hash
|
52
|
+
|
53
|
+
expected = { title: 'A Post', author_name: 'hi', pages: nil, publisher: nil }
|
54
|
+
assert_equal expected, result
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'has_many with nested serializer under the namespace' do
|
58
|
+
page = Page.new(number: 1, text: 'hello')
|
59
|
+
book = Book.new(title: 'A Post', author_name: 'hi', pages: [page])
|
60
|
+
|
61
|
+
result = ActiveModelSerializers::SerializableResource.new(book, namespace: Api::V3).serializable_hash
|
62
|
+
|
63
|
+
expected = {
|
64
|
+
title: 'A Post', author_name: 'hi',
|
65
|
+
publisher: nil,
|
66
|
+
pages: [{
|
67
|
+
number: 1, text: 'hello'
|
68
|
+
}]
|
69
|
+
}
|
70
|
+
assert_equal expected, result
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'belongs_to with nested serializer under the namespace' do
|
74
|
+
publisher = Publisher.new(name: 'Disney')
|
75
|
+
book = Book.new(title: 'A Post', author_name: 'hi', publisher: publisher)
|
76
|
+
|
77
|
+
result = ActiveModelSerializers::SerializableResource.new(book, namespace: Api::V3).serializable_hash
|
78
|
+
|
79
|
+
expected = {
|
80
|
+
title: 'A Post', author_name: 'hi',
|
81
|
+
pages: nil,
|
82
|
+
publisher: {
|
83
|
+
name: 'Disney'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
assert_equal expected, result
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# https://github.com/rails/rails/blob/v5.0.0.beta1/railties/test/isolation/abstract_unit.rb
|
2
4
|
|
3
5
|
# Usage Example:
|
@@ -41,6 +43,7 @@ require 'active_support/core_ext/string/access'
|
|
41
43
|
|
42
44
|
# These files do not require any others and are needed
|
43
45
|
# to run the tests
|
46
|
+
require 'active_support/testing/autorun'
|
44
47
|
require 'active_support/testing/isolation'
|
45
48
|
|
46
49
|
module TestHelpers
|
@@ -53,7 +56,7 @@ module TestHelpers
|
|
53
56
|
require 'rails'
|
54
57
|
require 'action_controller/railtie'
|
55
58
|
|
56
|
-
|
59
|
+
app = Class.new(Rails::Application) do
|
57
60
|
config.eager_load = false
|
58
61
|
config.session_store :cookie_store, key: '_myapp_session'
|
59
62
|
config.active_support.deprecation = :log
|
@@ -66,14 +69,18 @@ module TestHelpers
|
|
66
69
|
config.logger = fake_logger
|
67
70
|
Rails.application.routes.default_url_options = { host: 'example.com' }
|
68
71
|
end
|
69
|
-
|
72
|
+
def app.name; 'IsolatedRailsApp'; end # rubocop:disable Style/SingleLineMethods
|
73
|
+
app.respond_to?(:secrets) && app.secrets.secret_key_base = '3b7cd727ee24e8444053437c36cc66c4'
|
70
74
|
|
75
|
+
@app = app
|
71
76
|
yield @app if block_given?
|
72
77
|
@app.initialize!
|
73
78
|
end
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
77
|
-
|
78
|
-
|
82
|
+
module ActiveSupport
|
83
|
+
class TestCase
|
84
|
+
include TestHelpers::Generation
|
85
|
+
end
|
79
86
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rails5Shims
|
2
4
|
module ControllerTests
|
3
5
|
# https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
|
4
|
-
REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr].freeze
|
6
|
+
REQUEST_KWARGS = [:params, :headers, :session, :flash, :method, :body, :xhr].freeze
|
5
7
|
|
6
8
|
def get(path, *args)
|
7
9
|
fold_kwargs!(args)
|
@@ -30,7 +32,12 @@ module Rails5Shims
|
|
30
32
|
return unless hash.respond_to?(:key)
|
31
33
|
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
|
32
34
|
next unless hash.key?(kwarg)
|
33
|
-
|
35
|
+
value = hash.delete(kwarg)
|
36
|
+
if value.is_a? String
|
37
|
+
args.insert(0, value)
|
38
|
+
else
|
39
|
+
hash.merge! value
|
40
|
+
end
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
@@ -44,4 +51,5 @@ module Rails5Shims
|
|
44
51
|
end
|
45
52
|
if Rails::VERSION::MAJOR < 5
|
46
53
|
ActionController::TestCase.send :include, Rails5Shims::ControllerTests
|
54
|
+
ActionDispatch::IntegrationTest.send :include, Rails5Shims::ControllerTests
|
47
55
|
end
|
data/test/support/rails_app.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'support/isolated_unit'
|
2
4
|
module ActiveModelSerializers
|
3
5
|
RailsApplication = TestHelpers::Generation.make_basic_app do |app|
|
@@ -6,6 +8,8 @@ module ActiveModelSerializers
|
|
6
8
|
config.active_support.test_order = :random
|
7
9
|
config.action_controller.perform_caching = true
|
8
10
|
config.action_controller.cache_store = :memory_store
|
11
|
+
|
12
|
+
config.filter_parameters += [:password]
|
9
13
|
end
|
10
14
|
|
11
15
|
app.routes.default_url_options = { host: 'example.com' }
|
@@ -22,15 +26,6 @@ ActionController::TestCase.class_eval do
|
|
22
26
|
def setup
|
23
27
|
@routes = Routes
|
24
28
|
end
|
25
|
-
|
26
|
-
# For Rails5
|
27
|
-
# https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17
|
28
|
-
def assigns(key = nil)
|
29
|
-
warn "DEPRECATION: Calling 'assigns(#{key})' from #{caller[0]}"
|
30
|
-
assigns = {}.with_indifferent_access
|
31
|
-
@controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
|
32
|
-
key.nil? ? assigns : assigns[key]
|
33
|
-
end
|
34
29
|
end
|
35
30
|
|
36
31
|
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SerializationTesting
|
2
4
|
def config
|
3
5
|
ActiveModelSerializers.config
|
@@ -9,6 +11,22 @@ module SerializationTesting
|
|
9
11
|
ActiveModelSerializers::SerializableResource.new(obj).to_json
|
10
12
|
end
|
11
13
|
|
14
|
+
def with_namespace_separator(separator)
|
15
|
+
original_separator = ActiveModelSerializers.config.jsonapi_namespace_separator
|
16
|
+
ActiveModelSerializers.config.jsonapi_namespace_separator = separator
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
ActiveModelSerializers.config.jsonapi_namespace_separator = original_separator
|
20
|
+
end
|
21
|
+
|
22
|
+
def with_prepended_lookup(lookup_proc)
|
23
|
+
original_lookup = ActiveModelSerializers.config.serializer_lookup_cahin
|
24
|
+
ActiveModelSerializers.config.serializer_lookup_chain.unshift lookup_proc
|
25
|
+
yield
|
26
|
+
ensure
|
27
|
+
ActiveModelSerializers.config.serializer_lookup_cahin = original_lookup
|
28
|
+
end
|
29
|
+
|
12
30
|
# Aliased as :with_configured_adapter to clarify that
|
13
31
|
# this method tests the configured adapter.
|
14
32
|
# When not testing configuration, it may be preferable
|
@@ -31,6 +49,14 @@ module SerializationTesting
|
|
31
49
|
ActiveModelSerializers.config.replace(old_config)
|
32
50
|
end
|
33
51
|
|
52
|
+
def with_jsonapi_inflection(inflection)
|
53
|
+
original_inflection = ActiveModelSerializers.config.jsonapi_resource_type
|
54
|
+
ActiveModelSerializers.config.jsonapi_resource_type = inflection
|
55
|
+
yield
|
56
|
+
ensure
|
57
|
+
ActiveModelSerializers.config.jsonapi_resource_type = original_inflection
|
58
|
+
end
|
59
|
+
|
34
60
|
def with_serializer_lookup_disabled
|
35
61
|
original_serializer_lookup = ActiveModelSerializers.config.serializer_lookup_enabled
|
36
62
|
ActiveModelSerializers.config.serializer_lookup_enabled = false
|
@@ -44,10 +70,12 @@ module SerializationTesting
|
|
44
70
|
end
|
45
71
|
end
|
46
72
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
73
|
+
module Minitest
|
74
|
+
class Test
|
75
|
+
def before_setup
|
76
|
+
ActionController::Base.cache_store.clear
|
77
|
+
end
|
51
78
|
|
52
|
-
|
79
|
+
include SerializationTesting
|
80
|
+
end
|
53
81
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Configure Rails Environment
|
2
4
|
ENV['RAILS_ENV'] = 'test'
|
3
5
|
require 'bundler/setup'
|
@@ -9,6 +11,7 @@ rescue LoadError
|
|
9
11
|
STDERR.puts 'Running without SimpleCov'
|
10
12
|
end
|
11
13
|
|
14
|
+
require 'pry'
|
12
15
|
require 'timecop'
|
13
16
|
require 'rails'
|
14
17
|
require 'action_controller'
|
@@ -39,6 +42,18 @@ require 'minitest'
|
|
39
42
|
require 'minitest/autorun'
|
40
43
|
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
41
44
|
|
45
|
+
module TestHelper
|
46
|
+
module_function
|
47
|
+
|
48
|
+
def silence_warnings
|
49
|
+
original_verbose = $VERBOSE
|
50
|
+
$VERBOSE = nil
|
51
|
+
yield
|
52
|
+
ensure
|
53
|
+
$VERBOSE = original_verbose
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
require 'support/rails_app'
|
43
58
|
|
44
59
|
# require "rails/test_help"
|