debian-mirror-gitlab/spec/services/metrics/dashboard/system_dashboard_service_spec.rb

48 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
2019-10-12 21:52:04 +05:30
describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_store_caching do
2019-07-31 22:56:46 +05:30
include MetricsDashboardHelpers
2019-09-30 21:07:59 +05:30
set(:user) { create(:user) }
set(:project) { create(:project) }
2019-09-04 21:01:54 +05:30
set(:environment) { create(:environment, project: project) }
2019-07-31 22:56:46 +05:30
2019-09-30 21:07:59 +05:30
before do
project.add_maintainer(user)
end
2019-07-31 22:56:46 +05:30
describe 'get_dashboard' do
2020-01-01 13:55:28 +05:30
let(:dashboard_path) { described_class::DASHBOARD_PATH }
2019-09-30 21:07:59 +05:30
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
2019-07-31 22:56:46 +05:30
let(:service_call) { described_class.new(*service_params).get_dashboard }
it_behaves_like 'valid dashboard service response'
2019-09-30 21:07:59 +05:30
it_behaves_like 'raises error for users with insufficient permissions'
2020-01-01 13:55:28 +05:30
it_behaves_like 'caches the unprocessed dashboard for subsequent calls'
2019-07-31 22:56:46 +05:30
context 'when called with a non-system dashboard' do
let(:dashboard_path) { 'garbage/dashboard/path' }
2020-01-01 13:55:28 +05:30
# We want to always return the system dashboard.
2019-07-31 22:56:46 +05:30
it_behaves_like 'valid dashboard service response'
end
end
2019-09-04 21:01:54 +05:30
describe '::all_dashboard_paths' do
it 'returns the dashboard attributes' do
all_dashboards = described_class.all_dashboard_paths(project)
expect(all_dashboards).to eq(
[{
2020-01-01 13:55:28 +05:30
path: described_class::DASHBOARD_PATH,
display_name: described_class::DASHBOARD_NAME,
2019-12-26 22:10:19 +05:30
default: true,
system_dashboard: true
2019-09-04 21:01:54 +05:30
}]
)
end
end
2019-07-31 22:56:46 +05:30
end