Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSarah Yasonik <syasonik@gitlab.com>2019-06-14 18:55:08 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-06-14 18:55:08 +0300
commit1b7464ed84c3cf86d72b456f1c5220abdd01825a (patch)
tree8834deb46740b3a839b1fdf405c322b5437701d8 /spec
parentae853dba6b9e5f45aea0d14965c9691840db78f7 (diff)
Specify a dropdown name for dashboards
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/metrics/dashboard/finder_spec.rb4
-rw-r--r--spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb25
-rw-r--r--spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb14
3 files changed, 41 insertions, 2 deletions
diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
index bdcb5914575..29fe1ae8d9c 100644
--- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
@@ -49,7 +49,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi
describe '.find_all_paths' do
let(:all_dashboard_paths) { described_class.find_all_paths(project) }
- let(:system_dashboard) { { path: system_dashboard_path, default: true } }
+ let(:system_dashboard) { { path: system_dashboard_path, display_name: 'Default', default: true } }
it 'includes only the system dashboard by default' do
expect(all_dashboard_paths).to eq([system_dashboard])
@@ -60,7 +60,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi
let(:project) { project_with_dashboard(dashboard_path) }
it 'includes system and project dashboards' do
- project_dashboard = { path: dashboard_path, default: false }
+ project_dashboard = { path: dashboard_path, display_name: 'test.yml', default: false }
expect(all_dashboard_paths).to contain_exactly(system_dashboard, project_dashboard)
end
diff --git a/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb b/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb
index 794ac5f109b..57d82421b5d 100644
--- a/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb
@@ -59,4 +59,29 @@ describe Gitlab::Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_m
it_behaves_like 'misconfigured dashboard service response', :unprocessable_entity
end
end
+
+ describe '::all_dashboard_paths' do
+ let(:all_dashboards) { described_class.all_dashboard_paths(project) }
+
+ context 'when there are no project dashboards' do
+ it 'returns an empty array' do
+ expect(all_dashboards).to be_empty
+ end
+ end
+
+ context 'when there are project dashboards available' do
+ let(:dashboard_path) { '.gitlab/dashboards/test.yml' }
+ let(:project) { project_with_dashboard(dashboard_path) }
+
+ it 'returns the dashboard attributes' do
+ expect(all_dashboards).to eq(
+ [{
+ path: dashboard_path,
+ display_name: 'test.yml',
+ default: false
+ }]
+ )
+ end
+ end
+ end
end
diff --git a/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb b/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb
index 2648fe990de..2af745bd4d7 100644
--- a/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb
@@ -29,4 +29,18 @@ describe Gitlab::Metrics::Dashboard::SystemDashboardService, :use_clean_rails_me
it_behaves_like 'valid dashboard service response'
end
end
+
+ describe '::all_dashboard_paths' do
+ it 'returns the dashboard attributes' do
+ all_dashboards = described_class.all_dashboard_paths(project)
+
+ expect(all_dashboards).to eq(
+ [{
+ path: described_class::SYSTEM_DASHBOARD_PATH,
+ display_name: described_class::SYSTEM_DASHBOARD_NAME,
+ default: true
+ }]
+ )
+ end
+ end
end