summaryrefslogtreecommitdiff
path: root/spec/controllers/concerns/metrics_dashboard_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/concerns/metrics_dashboard_spec.rb')
-rw-r--r--spec/controllers/concerns/metrics_dashboard_spec.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb
index 39ddf687dca..f0c9874965e 100644
--- a/spec/controllers/concerns/metrics_dashboard_spec.rb
+++ b/spec/controllers/concerns/metrics_dashboard_spec.rb
@@ -76,6 +76,22 @@ RSpec.describe MetricsDashboard do
end
end
+ context 'when dashboard path includes encoded characters' do
+ let(:params) { { dashboard_path: 'dashboard%26copy.yml' } }
+
+ before do
+ allow(controller)
+ .to receive(:metrics_dashboard_params)
+ .and_return(params)
+ end
+
+ it 'decodes dashboard path' do
+ expect(::Gitlab::Metrics::Dashboard::Finder).to receive(:find).with(anything, anything, hash_including(dashboard_path: 'dashboard&copy.yml'))
+
+ json_response
+ end
+ end
+
context 'when parameters are provided and the list of all dashboards is required' do
before do
allow(controller).to receive(:include_all_dashboards?).and_return(true)
@@ -88,13 +104,28 @@ RSpec.describe MetricsDashboard do
context 'in all_dashboard list' do
let(:system_dashboard) { json_response['all_dashboards'].find { |dashboard| dashboard["system_dashboard"] == true } }
- let(:project_dashboard) { json_response['all_dashboards'].find { |dashboard| dashboard["system_dashboard"] == false } }
+
+ let(:project_dashboard) do
+ json_response['all_dashboards'].find do |dashboard|
+ dashboard['path'] == '.gitlab/dashboards/test.yml'
+ end
+ end
it 'includes project_blob_path only for project dashboards' do
expect(system_dashboard['project_blob_path']).to be_nil
expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml")
end
+ it 'allows editing only for project dashboards' do
+ expect(system_dashboard['can_edit']).to be(false)
+ expect(project_dashboard['can_edit']).to be(true)
+ end
+
+ it 'includes out_of_the_box_dashboard key' do
+ expect(system_dashboard['out_of_the_box_dashboard']).to be(true)
+ expect(project_dashboard['out_of_the_box_dashboard']).to be(false)
+ end
+
describe 'project permissions' do
using RSpec::Parameterized::TableSyntax