summaryrefslogtreecommitdiff
path: root/spec/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 18:09:32 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 18:09:32 +0000
commited5add1c2f001c9bd54e664b32f212de172eca6a (patch)
treef9449cbecde36706f25a62f426b5398566ae5cca /spec/graphql
parentde2fb5b82c92c90f90ed67ced45143c04e934fb8 (diff)
downloadgitlab-ce-ed5add1c2f001c9bd54e664b32f212de172eca6a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb44
-rw-r--r--spec/graphql/types/environment_type_spec.rb2
-rw-r--r--spec/graphql/types/metrics/dashboard_type_spec.rb15
3 files changed, 60 insertions, 1 deletions
diff --git a/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb b/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb
new file mode 100644
index 00000000000..6a8eb8a65af
--- /dev/null
+++ b/spec/graphql/resolvers/metrics/dashboard_resolver_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Resolvers::Metrics::DashboardResolver do
+ include GraphqlHelpers
+
+ let_it_be(:current_user) { create(:user) }
+
+ describe '#resolve' do
+ subject(:resolve_dashboard) { resolve(described_class, obj: parent_object, args: args, ctx: { current_user: current_user }) }
+
+ let(:args) do
+ {
+ path: 'config/prometheus/common_metrics.yml'
+ }
+ end
+
+ context 'for environment' do
+ let(:project) { create(:project) }
+ let(:parent_object) { create(:environment, project: project) }
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ it 'use ActiveModel class to find matching dashboard', :aggregate_failures do
+ expected_arguments = { project: project, user: current_user, path: args[:path], options: { environment: parent_object } }
+
+ expect(PerformanceMonitoring::PrometheusDashboard).to receive(:find_for).with(expected_arguments).and_return(PerformanceMonitoring::PrometheusDashboard.new)
+ expect(resolve_dashboard).to be_instance_of PerformanceMonitoring::PrometheusDashboard
+ end
+
+ context 'without parent object' do
+ let(:parent_object) { nil }
+
+ it 'returns nil', :aggregate_failures do
+ expect(PerformanceMonitoring::PrometheusDashboard).not_to receive(:find_for)
+ expect(resolve_dashboard).to be_nil
+ end
+ end
+ end
+ end
+end
diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb
index b3711fa2f5c..24a8bddfa6a 100644
--- a/spec/graphql/types/environment_type_spec.rb
+++ b/spec/graphql/types/environment_type_spec.rb
@@ -7,7 +7,7 @@ describe GitlabSchema.types['Environment'] do
it 'has the expected fields' do
expected_fields = %w[
- name id state
+ name id state metrics_dashboard
]
expect(described_class).to have_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/metrics/dashboard_type_spec.rb b/spec/graphql/types/metrics/dashboard_type_spec.rb
new file mode 100644
index 00000000000..4795fd77537
--- /dev/null
+++ b/spec/graphql/types/metrics/dashboard_type_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe GitlabSchema.types['MetricsDashboard'] do
+ it { expect(described_class.graphql_name).to eq('MetricsDashboard') }
+
+ it 'has the expected fields' do
+ expected_fields = %w[
+ path
+ ]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
+end