Sha256: fd399592899fbb8cc7f0bd003124de154faad45158dd6026adab00f12fa94689

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

module ActiveModel
  class Serializer
    class Association
      class BuildSerializerTest < Minitest::Test
        def setup
          @association = Association::HasOne.new('post', serializer: PostSerializer)
          @post = Post.new({ title: 'Title 1', body: 'Body 1', date: '1/1/2000' })
          @user = User.new
        end

        def test_build_serializer_for_array_called_twice
          2.times do
            serializer = @association.build_serializer(@post)
            assert_instance_of(PostSerializer, serializer)
          end
        end

        def test_build_serializer_from_in_a_namespace
          assoc      = Association::HasOne.new('profile')
          serializer = TestNamespace::UserSerializer.new(@user).build_serializer(assoc)

          assert_instance_of(TestNamespace::ProfileSerializer, serializer)
        end

        def test_build_serializer_with_prefix
          assoc      = Association::HasOne.new('profile', prefix: :short)
          serializer = UserSerializer.new(@user).build_serializer(assoc)

          assert_instance_of(ShortProfileSerializer, serializer)
        end
      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/associations/build_serializer_test.rb
active_model_serializers-0.9.12 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.11 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.9 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.8 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.7 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.6 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.5 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.4 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.3 test/unit/active_model/serializer/associations/build_serializer_test.rb
active_model_serializers-0.9.1 test/unit/active_model/serializer/associations/build_serializer_test.rb