debian-mirror-gitlab/spec/requests/admin/version_check_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
Ruby
Raw Normal View History

2022-01-26 12:08:38 +05:30
# 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