summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/middleware/sidekiq_web_static_spec.rb
blob: e6815a46a5649c6d4f643bb03ad95c11a8da68f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Middleware::SidekiqWebStatic do
  let(:app) { double(:app) }
  let(:middleware) { described_class.new(app) }
  let(:env) { {} }

  describe '#call' do
    before do
      env['HTTP_X_SENDFILE_TYPE'] = 'X-Sendfile'
      env['PATH_INFO'] = path
    end

    context 'with an /admin/sidekiq route' do
      let(:path) { '/admin/sidekiq/javascripts/application.js'}

      it 'deletes the HTTP_X_SENDFILE_TYPE header' do
        expect(app).to receive(:call)

        middleware.call(env)

        expect(env['HTTP_X_SENDFILE_TYPE']).to be_nil
      end
    end

    context 'with some static asset route' do
      let(:path) { '/assets/test.png' }

      it 'keeps the HTTP_X_SENDFILE_TYPE header' do
        expect(app).to receive(:call)

        middleware.call(env)

        expect(env['HTTP_X_SENDFILE_TYPE']).to eq('X-Sendfile')
      end
    end
  end
end