Sha256: 67c6264c4501d6131176ba36e43b080c2fafea122889b4904664b32fc770de77

Contents?: true

Size: 698 Bytes

Versions: 12

Compression:

Stored size: 698 Bytes

Contents

require "test_helper"

class NoSerializationScopeTest < ActionController::TestCase
  class ScopeSerializer
    def initialize(object, options)
      @object, @options = object, options
    end

    def as_json(*)
      { scope: @options[:scope].as_json }
    end
  end

  class ScopeSerializable
    def active_model_serializer
      ScopeSerializer
    end
  end

  class NoSerializationScopeController < ActionController::Base
    serialization_scope nil

    def index
      render json: ScopeSerializable.new
    end
  end

  tests NoSerializationScopeController

  def test_disabled_serialization_scope
    get :index, format: :json
    assert_equal '{"scope":null}', @response.body
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gpi-active_model_serializers-0.8.5 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.5.alpha1 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4.alpha5 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4.alpha4 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4.alpha3 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4.alpha2 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.4.alpha1 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.3.rc1 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.3.alpha2 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.3.alpha1 test/no_serialization_scope_test.rb
gpi-active_model_serializers-0.8.2 test/no_serialization_scope_test.rb