root option is working (fixed #986)

This commit is contained in:
Marek Pietrucha 2015-07-06 16:50:25 +02:00 committed by vyrak bunleang
parent d7140949cd
commit e5ccb8e4dd
2 changed files with 20 additions and 1 deletions

View File

@ -169,7 +169,7 @@ module ActiveModel
end
def json_key
self.class.root_name
@root || self.class.root_name
end
def id

View File

@ -0,0 +1,19 @@
require 'test_helper'
module ActiveModel
class Serializer
class RootTest < Minitest::Test
def setup
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@profile_serializer = ProfileSerializer.new(@post, {root: 'smth'})
end
def test_overwrite_root
setup
assert_equal('smth', @profile_serializer.json_key)
end
end
end
end