debian-mirror-gitlab/spec/requests/api/graphql/metadata_query_spec.rb

65 lines
1.7 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'getting project information' do
2019-07-07 11:18:12 +05:30
include GraphqlHelpers
let(:query) { graphql_query_for('metadata', {}, all_graphql_fields_for('Metadata')) }
context 'logged in' do
2021-06-08 01:23:25 +05:30
let(:expected_data) do
{
2019-07-07 11:18:12 +05:30
'metadata' => {
'version' => Gitlab::VERSION,
2021-06-08 01:23:25 +05:30
'revision' => Gitlab.revision,
'kas' => {
'enabled' => Gitlab::Kas.enabled?,
'version' => expected_kas_version,
'externalUrl' => expected_kas_external_url
}
2019-07-07 11:18:12 +05:30
}
2021-06-08 01:23:25 +05:30
}
end
context 'kas is enabled' do
let(:expected_kas_version) { Gitlab::Kas.version }
let(:expected_kas_external_url) { Gitlab::Kas.external_url }
before do
allow(Gitlab::Kas).to receive(:enabled?).and_return(true)
post_graphql(query, current_user: create(:user))
end
it 'returns version, revision, kas_enabled, kas_version, kas_external_url' do
expect(graphql_errors).to be_nil
expect(graphql_data).to eq(expected_data)
end
end
context 'kas is disabled' do
let(:expected_kas_version) { nil }
let(:expected_kas_external_url) { nil }
before do
allow(Gitlab::Kas).to receive(:enabled?).and_return(false)
post_graphql(query, current_user: create(:user))
end
it 'returns version and revision' do
expect(graphql_errors).to be_nil
expect(graphql_data).to eq(expected_data)
end
2019-07-07 11:18:12 +05:30
end
end
context 'anonymous user' do
it 'returns nothing' do
post_graphql(query, current_user: nil)
expect(graphql_errors).to be_nil
expect(graphql_data).to eq('metadata' => nil)
end
end
end