Add alias_method ActiveModel::Serializer.root= to be consistency with ActiveModel::ArraySerializer

This commit is contained in:
Samnang Chhun 2012-11-20 00:29:00 +07:00
parent 6ca430cec3
commit 96ce310595
2 changed files with 6 additions and 0 deletions

View File

@ -204,6 +204,7 @@ module ActiveModel
def root(name)
self._root = name
end
alias_method :root=, :root
def inherited(klass) #:nodoc:
return if klass.anonymous?

View File

@ -382,7 +382,12 @@ class SerializerTest < ActiveModel::TestCase
root false
end
another_serializer = Class.new(BlogSerializer) do
self.root = false
end
assert_equal({ :author => nil }, serializer.new(blog, :scope => user).as_json)
assert_equal({ :author => nil }, another_serializer.new(blog, :scope => user).as_json)
# test inherited false root
serializer = Class.new(serializer)