Fix global `` self.root = false ``

Using the on_load hook does not change the defined root on
Serializer#inherited.

Related to #179
This commit is contained in:
Rafael Felix
2013-01-03 16:01:46 -02:00
parent cef10cf01d
commit 82951c1f8a
2 changed files with 25 additions and 10 deletions

View File

@@ -274,6 +274,23 @@ class SerializerTest < ActiveModel::TestCase
assert_equal({ :author => nil }, serializer.new(blog, :scope => user).as_json)
end
def test_root_false_on_load_active_model_serializers
begin
ActiveSupport.on_load(:active_model_serializers) do
self.root = false
end
blog = Blog.new
serializer = BlogSerializer.new(blog)
assert_equal({ :author => nil }, serializer.as_json)
ensure
ActiveSupport.on_load(:active_model_serializers) do
self.root = nil
end
end
end
def test_embed_ids
serializer = post_serializer