Sha256: 7f249bb482c6f83853cd59d7b2c0eae3d286bc1ab4fe505112b3c0c042d65512

Contents?: true

Size: 1 KB

Versions: 12

Compression:

Stored size: 1 KB

Contents

require 'test_helper'

module ActiveModel
  class Serializer
    class AssociationMacrosTest < Minitest::Test
      AuthorSummarySerializer = Class.new
      class AssociationsTestSerializer < Serializer
        belongs_to :author, serializer: AuthorSummarySerializer
        has_many :comments
        has_one :category
      end

      def before_setup
        @reflections = AssociationsTestSerializer._reflections
      end

      def test_has_one_defines_reflection
        has_one_reflection = HasOneReflection.new(:category, {})

        assert_includes(@reflections, has_one_reflection)
      end

      def test_has_many_defines_reflection
        has_many_reflection = HasManyReflection.new(:comments, {})

        assert_includes(@reflections, has_many_reflection)
      end

      def test_belongs_to_defines_reflection
        belongs_to_reflection = BelongsToReflection.new(:author, serializer: AuthorSummarySerializer)

        assert_includes(@reflections, belongs_to_reflection)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
active_model_serializers-0.10.0.rc3 test/serializers/association_macros_test.rb
cheap_ams-0.10.11 test/serializers/association_macros_test.rb
cheap_ams-0.10.10 test/serializers/association_macros_test.rb
cheap_ams-0.10.8 test/serializers/association_macros_test.rb
cheap_ams-0.10.7 test/serializers/association_macros_test.rb
cheap_ams-0.10.6 test/serializers/association_macros_test.rb
cheap_ams-0.10.5 test/serializers/association_macros_test.rb
cheap_ams-0.10.4 test/serializers/association_macros_test.rb
cheap_ams-0.10.3 test/serializers/association_macros_test.rb
cheap_ams-0.10.2 test/serializers/association_macros_test.rb
cheap_ams-0.10.1 test/serializers/association_macros_test.rb
cheap_ams-0.10.0.rc2 test/serializers/association_macros_test.rb