summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/render_timeout_spec.rb
blob: f322d71867b32c7807f1a088953dcf9d08344e87 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::RenderTimeout do
  def expect_timeout(period)
    block = proc {}

    expect(Timeout).to receive(:timeout).with(period) do |_, &block|
      expect(block).to eq(block)
    end

    described_class.timeout(&block)
  end

  it 'utilizes timeout for web' do
    expect_timeout(described_class::FOREGROUND)
  end

  it 'utilizes longer timeout for sidekiq' do
    allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(true)

    expect_timeout(described_class::BACKGROUND)
  end
end