mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Revert "clean up lazy loading of serialization support for
ActiveRecord::Base and ActionController::Base"
The whole idea of having a lazy hook is that it can be executed
in the context of different targets. The moment you hardcode the class,
the hooks can no longer run in the proper context.
This reverts commit 506e2ac9ad.
This commit is contained in:
parent
634f5ba91e
commit
be70c5c846
@ -57,7 +57,7 @@ module ActiveModel::SerializerSupport
|
||||
end
|
||||
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
ActiveRecord::Base.send(:include, ActiveModel::SerializerSupport)
|
||||
include ActiveModel::SerializerSupport
|
||||
end
|
||||
|
||||
module ActiveModel::ArraySerializerSupport
|
||||
@ -78,7 +78,7 @@ begin
|
||||
require 'action_controller/serialization'
|
||||
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
ActionController::Base.send(:include, ActionController::Serialization)
|
||||
include ::ActionController::Serialization
|
||||
end
|
||||
rescue LoadError => ex
|
||||
# rails on installed, continuing
|
||||
|
||||
@ -9,8 +9,6 @@ class RandomModelCollection
|
||||
end
|
||||
|
||||
module ActiveRecord
|
||||
class Base
|
||||
end
|
||||
class Relation
|
||||
end
|
||||
end
|
||||
@ -28,15 +26,5 @@ class SerializerSupportTest < ActiveModel::TestCase
|
||||
ActiveSupport.run_load_hooks(:active_record)
|
||||
assert_equal ActiveModel::ArraySerializer, ActiveRecord::Relation.new.active_model_serializer
|
||||
end
|
||||
|
||||
test "it automatically includes serializer support in active_record/base" do
|
||||
ActiveSupport.run_load_hooks(:active_record)
|
||||
assert ActiveRecord::Base.new.respond_to?(:active_model_serializer)
|
||||
end
|
||||
|
||||
test "it automatically includes serializer support in action_controller/base" do
|
||||
ActiveSupport.run_load_hooks(:action_controller)
|
||||
assert ActionController::Base.new.respond_to?(:serialization_scope)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user