Sha256: e240ed76d76f81a8a351e525fe956773e04f727460dd0eb0495820f32ef928e3

Contents?: true

Size: 768 Bytes

Versions: 11

Compression:

Stored size: 768 Bytes

Contents

require 'test_helper'

module ActiveModel
  class Serializer
    class HasOneAndHasManyTest < Minitest::Test
      def setup
        @post = SpecialPost.new({ title: 'T1', body: 'B1'})
        @post_serializer = SpecialPostSerializer.new(@post)
      end

      def teardown
      end

      def test_side_load_has_one_and_has_many_in_same_array
        assert_equal({
          "post" => {
            title: 'T1',
            body: 'B1',
            'comment_ids' => @post.comments.map { |c| c.object_id },
            'special_comment_id' => @post_serializer.special_comment.object_id,
          },
          "comments" => [{ content: 'C1' }, { content: 'C2' }, { content: 'special' }]
        }, @post_serializer.as_json(root: 'post'))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_model_serializers-0.9.13 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.12 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.11 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.9 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.8 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.7 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.6 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.5 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.4 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.3 test/unit/active_model/serializer/has_one_and_has_many_test.rb
active_model_serializers-0.9.1 test/unit/active_model/serializer/has_one_and_has_many_test.rb