mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 22:36:50 +00:00
Isolated Testing - Rake test inspired by https://github.com/rails/rails/blob/v5.0.0.beta1/activejob/Rakefile - Isolated unit inspired by - https://github.com/rails/rails/blob/v5.0.0.beta1/railties/test/isolation/abstract_unit.rb - https://github.com/rails/rails/blob/v5.0.0.beta1/activemodel/test/cases/railtie_test.rb Misc - Turns out `mattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }` was always nil until the Railtie was loaded, since mattr_accessor block defaults don't really work on modules, but on the classes that include them. - Commented on important on Rails being required first for caching to work. - In isolated tests, `active_support/core_ext/object/with_options` is required.
24 lines
657 B
Ruby
24 lines
657 B
Ruby
require 'active_model'
|
|
require 'active_support'
|
|
require 'active_support/core_ext/object/with_options'
|
|
module ActiveModelSerializers
|
|
extend ActiveSupport::Autoload
|
|
autoload :Model
|
|
autoload :Callbacks
|
|
autoload :Deserialization
|
|
autoload :Logging
|
|
autoload :Test
|
|
|
|
class << self; attr_accessor :logger; end
|
|
self.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
|
|
|
|
def self.config
|
|
ActiveModel::Serializer.config
|
|
end
|
|
|
|
require 'active_model/serializer/version'
|
|
require 'active_model/serializer'
|
|
require 'active_model/serializable_resource'
|
|
require 'active_model_serializers/railtie' if defined?(::Rails)
|
|
end
|