Sha256: 277a0eaf7302d166795b706a7f939430fb849b44baa1aa44f2b1c500fc2a646b

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 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
    assert_equal '{"scope":null}', @response.body
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_model_serializers-0.7.0 test/no_serialization_scope_test.rb
active_model_serializers-0.6.0 test/no_serialization_scope_test.rb