Sha256: 026865df51461466c6c20d743e6c3a5136301d5535622ea7283c767c844360b9

Contents?: true

Size: 928 Bytes

Versions: 21

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'

describe Rack::Sendfile do
  subject do
    send_file = file_streamer
    app = Class.new(Grape::API) do
      use Rack::Sendfile
      format :json
      get do
        file send_file
      end
    end

    options = {
      method: 'GET',
      'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect',
      'HTTP_X_ACCEL_MAPPING' => '/accel/mapping/=/replaced/'
    }
    env = Rack::MockRequest.env_for('/', options)
    app.call(env)
  end

  context do
    let(:file_streamer) do
      double(:file_streamer, to_path: '/accel/mapping/some/path')
    end

    it 'contains Sendfile headers' do
      headers = subject[1]
      expect(headers).to include('X-Accel-Redirect')
    end
  end

  context do
    let(:file_streamer) do
      double(:file_streamer)
    end

    it 'not contains Sendfile headers' do
      headers = subject[1]
      expect(headers).to_not include('X-Accel-Redirect')
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/spec/grape/integration/rack_sendfile_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.5 spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.4 spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.3 spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.2 spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.1 spec/grape/integration/rack_sendfile_spec.rb
grape-1.2.0 spec/grape/integration/rack_sendfile_spec.rb
grape-1.1.0 spec/grape/integration/rack_sendfile_spec.rb
grape-1.0.3 spec/grape/integration/rack_sendfile_spec.rb
grape-1.0.2 spec/grape/integration/rack_sendfile_spec.rb
grape-1.0.1 spec/grape/integration/rack_sendfile_spec.rb
grape-1.0.0 spec/grape/integration/rack_sendfile_spec.rb
grape-0.19.2 spec/grape/integration/rack_sendfile_spec.rb
grape-0.19.1 spec/grape/integration/rack_sendfile_spec.rb
grape-0.19.0 spec/grape/integration/rack_sendfile_spec.rb
grape-0.18.0 spec/grape/integration/rack_sendfile_spec.rb
grape-0.17.0 spec/grape/integration/rack_sendfile_spec.rb
grape-0.16.2 spec/grape/integration/rack_sendfile_spec.rb
grape-0.16.1 spec/grape/integration/rack_sendfile_spec.rb