debian-mirror-gitlab/spec/requests/api/graphql/project/grafana_integration_spec.rb

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

64 lines
1.6 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Getting Grafana Integration', feature_category: :metrics do
2020-03-13 15:44:24 +05:30
include GraphqlHelpers
let_it_be(:project) { create(:project, :repository) }
2022-04-04 11:22:00 +05:30
let_it_be(:current_user) { project.first_owner }
2020-03-13 15:44:24 +05:30
let_it_be(:grafana_integration) { create(:grafana_integration, project: project) }
let(:fields) do
<<~QUERY
#{all_graphql_fields_for('GrafanaIntegration'.classify)}
QUERY
end
let(:query) do
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
query_graphql_field('grafanaIntegration', {}, fields)
)
end
context 'with grafana integration data' do
let(:integration_data) { graphql_data['project']['grafanaIntegration'] }
context 'without project admin permissions' do
let(:user) { create(:user) }
before do
project.add_developer(user)
post_graphql(query, current_user: user)
end
it_behaves_like 'a working graphql query'
2020-05-24 23:13:21 +05:30
specify { expect(integration_data).to be nil }
2020-03-13 15:44:24 +05:30
end
context 'with project admin permissions' do
before do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
2020-05-24 23:13:21 +05:30
specify { expect(integration_data['grafanaUrl']).to eql grafana_integration.grafana_url }
2020-03-13 15:44:24 +05:30
2020-05-24 23:13:21 +05:30
specify do
2020-03-13 15:44:24 +05:30
expect(
integration_data['createdAt']
).to eql grafana_integration.created_at.strftime('%Y-%m-%dT%H:%M:%SZ')
end
2020-05-24 23:13:21 +05:30
specify do
2020-03-13 15:44:24 +05:30
expect(
integration_data['updatedAt']
).to eql grafana_integration.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ')
end
end
end
end