mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
root option is working (fixed #986)
This commit is contained in:
parent
d7140949cd
commit
e5ccb8e4dd
@ -169,7 +169,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def json_key
|
def json_key
|
||||||
self.class.root_name
|
@root || self.class.root_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
|||||||
19
test/serializers/root_test.rb
Normal file
19
test/serializers/root_test.rb
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user