Sha256: 3547807de58d567e68f34496d59e1b2577d7de47d1ff15404521bc4a15981cae

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 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

5 entries across 5 versions & 1 rubygems

Version Path
active_model_serializers-0.8.4 test/no_serialization_scope_test.rb
active_model_serializers-0.8.3 test/no_serialization_scope_test.rb
active_model_serializers-0.8.2 test/no_serialization_scope_test.rb
active_model_serializers-0.8.1 test/no_serialization_scope_test.rb
active_model_serializers-0.8.0 test/no_serialization_scope_test.rb