mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Merge pull request #152 from samnang/setting_root
Fixed root(false) vs root=false inconsistency
This commit is contained in:
commit
5d45f5ec6f
@ -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?
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user