blob: cece36f06b26ae19720f8019020715847ed55912 (
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.new
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
|