blob: 7e2f33d5bc5b70c637a791446bfaff38fd4ebff7 (
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
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::VersionCheckController, :enable_admin_mode do
let(:admin) { create(:admin) }
before do
sign_in(admin)
end
describe 'GET #version_check' do
context 'when VersionCheck.response is nil' do
before do
allow_next_instance_of(VersionCheck) do |instance|
allow(instance).to receive(:response).and_return(nil)
end
get admin_version_check_path
end
it 'returns nil' do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_nil
end
it 'sets no-cache headers' do
expect(response.headers['Cache-Control']).to eq('max-age=0, private, must-revalidate')
end
end
context 'when VersionCheck.response is valid' do
before do
allow_next_instance_of(VersionCheck) do |instance|
allow(instance).to receive(:response).and_return({ "severity" => "success" })
end
get admin_version_check_path
end
it 'returns the valid data' do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ "severity" => "success" })
end
it 'sets proper cache headers' do
expect(response.headers['Cache-Control']).to eq('max-age=60, private')
end
end
end
end
|