Merge pull request #152 from samnang/setting_root

Fixed root(false) vs root=false inconsistency
This commit is contained in:
Steve Klabnik 2012-11-20 02:36:09 -08:00
commit 5d45f5ec6f
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)