Sha256: 63ff091faf01f52e7e19d81aeb624e86f056d62993c4cb38d44711cb158e71f1

Contents?: true

Size: 991 Bytes

Versions: 14

Compression:

Stored size: 991 Bytes

Contents

require 'test_helper'

module ActiveModel
  class Serializer
    class MetaTest < Minitest::Test
      def setup
        @profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
      end

      def test_meta
        profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta: { total: 10 })

        assert_equal({
          'profile' => {
            name: 'Name 1',
            description: 'Description 1'
          },
          meta: {
            total: 10
          }
        }, profile_serializer.as_json)
      end

      def test_meta_using_meta_key
        profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta_key: :my_meta, my_meta: { total: 10 })

        assert_equal({
          'profile' => {
            name: 'Name 1',
            description: 'Description 1'
          },
          my_meta: {
            total: 10
          }
        }, profile_serializer.as_json)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
active_model_serializers-0.9.13 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.12 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.11 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.9 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.8 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.7 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.6 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.5 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.4 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.3 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.2 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.1 test/unit/active_model/serializer/meta_test.rb
active_model_serializers-0.9.0 test/unit/active_model/serializer/meta_test.rb
active_model_serializers_rails_2.3-0.9.0.alpha1 test/unit/active_model/serializer/meta_test.rb