Welcome to mirror list, hosted at ThFree Co, Russian Federation.

graceful_timeout_handling_spec.rb « concerns « controllers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e496d12856b2dc71ad0bc367302250f940b644cf (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
41
42
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GracefulTimeoutHandling, type: :controller do
  controller(ApplicationController) do
    include GracefulTimeoutHandling

    skip_before_action :authenticate_user!

    def index
      raise ActiveRecord::QueryCanceled
    end
  end

  context 'for json request' do
    subject { get :index, format: :json }

    it 'renders graceful error message' do
      subject

      expect(json_response['error']).to eq(_('There is too much data to calculate. Please change your selection.'))
      expect(response.code).to eq '200'
    end

    it 'logs exception' do
      expect(Gitlab::ErrorTracking).to receive(:track_exception).with(kind_of(ActiveRecord::QueryCanceled))

      subject
    end
  end

  context 'for html request' do
    subject { get :index, format: :html }

    it 'has no effect' do
      expect do
        subject
      end.to raise_error(ActiveRecord::QueryCanceled)
    end
  end
end