active_model_serializers/lib/active_model_serializers.rb
Mauro George c0b99c980c Bring back assert_serializer for controller testing
The `assert_serializer` test helper was added in 0.9.0.apha1[1],
and was not included in 0.10.

This patch brings back the `assert_serializer` test helper. This is the last
revision[2] that has the helper. The original helper was used as base.

[1]: https://github.com/rails-api/active_model_serializers/pull/596
[2]: 610aeb2e92

- Create the AssertSerializer

- Use the Test namespace

- Make the tests pass on the Rails master
  - Rails 5 does not include `assert_template` but we need this on the tests of
the helper.
  - This add the `rails-controller-testing` to keep support on `assert_template`.

- Only load test helpers in the test environment
2016-01-13 20:54:22 -06:00

34 lines
925 B
Ruby

require 'active_model'
require 'active_support'
require 'action_controller'
require 'action_controller/railtie'
module ActiveModelSerializers
mattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
def self.config
ActiveModel::Serializer.config
end
extend ActiveSupport::Autoload
autoload :Model
autoload :Callbacks
autoload :Deserialization
autoload :Logging
autoload :Test
end
require 'active_model/serializer'
require 'active_model/serializable_resource'
require 'active_model/serializer/version'
require 'action_controller/serialization'
ActiveSupport.on_load(:action_controller) do
ActiveSupport.run_load_hooks(:active_model_serializers, ActiveModelSerializers)
include ::ActionController::Serialization
ActionDispatch::Reloader.to_prepare do
ActiveModel::Serializer.serializers_cache.clear
end
end
require 'active_model/serializer/railtie'