mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
embed_in_root is now side_load
This commit is contained in:
@@ -63,7 +63,7 @@ module ActiveModel
|
||||
|
||||
ARPostSerializer._associations.each_value do |association|
|
||||
association.embed = options[:embed]
|
||||
association.embed_in_root = options[:include]
|
||||
association.side_load = options[:include]
|
||||
end
|
||||
|
||||
yield
|
||||
|
||||
@@ -75,7 +75,7 @@ module ActiveModel
|
||||
|
||||
assert association.embed_ids?
|
||||
assert !association.embed_objects?
|
||||
assert association.embed_in_root
|
||||
assert association.side_load
|
||||
ensure
|
||||
PostSerializer._associations[:comments] = old_association
|
||||
CONFIG.clear
|
||||
|
||||
@@ -25,7 +25,7 @@ module ActiveModel
|
||||
@association = PostSerializer._associations[:comments]
|
||||
@old_association = @association.dup
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
@post = Post.new({ title: 'Title 1', body: 'Body 1', date: '1/1/2000' })
|
||||
@post_serializer = PostSerializer.new(@post)
|
||||
@post_serializer.instance_eval do
|
||||
|
||||
@@ -86,7 +86,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_including_objects_serialization_using_serializable_hash
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
|
||||
assert_equal({
|
||||
title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id }
|
||||
@@ -95,7 +95,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_including_objects_serialization_using_as_json
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
|
||||
assert_equal({
|
||||
'post' => { title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } },
|
||||
@@ -105,7 +105,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_nothing_including_objects_serialization_using_as_json
|
||||
@association.embed = nil
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
|
||||
assert_equal({
|
||||
'post' => { title: 'Title 1', body: 'Body 1' },
|
||||
@@ -115,7 +115,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_using_a_given_serializer
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
@association.serializer_class = Class.new(ActiveModel::Serializer) do
|
||||
def content
|
||||
'fake'
|
||||
|
||||
@@ -99,7 +99,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_including_objects_serialization_using_serializable_hash
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
|
||||
assert_equal({
|
||||
name: 'Name 1', email: 'mail@server.com', 'profile_id' => @user.profile.object_id
|
||||
@@ -108,7 +108,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_including_objects_serialization_using_as_json
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
|
||||
assert_equal({
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', 'profile_id' => @user.profile.object_id },
|
||||
@@ -118,7 +118,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_using_a_given_serializer
|
||||
@association.embed = :ids
|
||||
@association.embed_in_root = true
|
||||
@association.side_load = true
|
||||
@association.serializer_class = Class.new(ActiveModel::Serializer) do
|
||||
def name
|
||||
'fake'
|
||||
|
||||
Reference in New Issue
Block a user