Commit cd46f7f9 authored by Ryan Cobb's avatar Ryan Cobb

Change route and add comments

Change route from /d to /metrics. Also add comments linking to issue.
parent 8d19dd96
# frozen_string_literal: true # frozen_string_literal: true
class Projects::EnvironmentsController < Projects::ApplicationController class Projects::EnvironmentsController < Projects::ApplicationController
# Metrics dashboard code is getting decoupled from environments and is being moved
# into app/controllers/projects/metrics_dashboard_controller.rb
# See https://gitlab.com/gitlab-org/gitlab/-/issues/226002 for more details.
include MetricsDashboard include MetricsDashboard
layout 'project' layout 'project'
......
# frozen_string_literal: true # frozen_string_literal: true
module Projects module Projects
class MetricsDashboardController < Projects::ApplicationController class MetricsDashboardController < Projects::ApplicationController
# Metrics dashboard code is in the process of being decoupled from environments
# and is getting moved to this controller. Some code may be duplicated from
# app/controllers/projects/environments_controller.rb
# See https://gitlab.com/gitlab-org/gitlab/-/issues/226002 for more details.
before_action :authorize_metrics_dashboard! before_action :authorize_metrics_dashboard!
before_action do before_action do
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
......
...@@ -25,7 +25,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -25,7 +25,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# Use this scope for all new project routes. # Use this scope for all new project routes.
scope '-' do scope '-' do
get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
get 'd(/:dashboard_path)', constraints: { dashboard_path: /.+\.yml/ }, get 'metrics(/:dashboard_path)', constraints: { dashboard_path: /.+\.yml/ },
to: 'metrics_dashboard#show', as: :metrics_dashboard, format: false to: 'metrics_dashboard#show', as: :metrics_dashboard, format: false
resources :artifacts, only: [:index, :destroy] resources :artifacts, only: [:index, :destroy]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe 'metrics dashboard page' do RSpec.describe 'metrics dashboard page' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:environment) { create(:environment, project: project) } let_it_be(:environment) { create(:environment, project: project) }
let_it_be(:environment2) { create(:environment, project: project) } let_it_be(:environment2) { create(:environment, project: project) }
...@@ -13,7 +13,7 @@ describe 'metrics dashboard page' do ...@@ -13,7 +13,7 @@ describe 'metrics dashboard page' do
login_as(user) login_as(user)
end end
describe 'GET /:namespace/:project/-/d' do describe 'GET /:namespace/:project/-/metrics' do
it 'returns 200' do it 'returns 200' do
send_request send_request
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -25,7 +25,7 @@ describe 'metrics dashboard page' do ...@@ -25,7 +25,7 @@ describe 'metrics dashboard page' do
end end
end end
describe 'GET /:namespace/:project/-/d?environment=:environment.id' do describe 'GET /:namespace/:project/-/metrics?environment=:environment.id' do
it 'returns 200' do it 'returns 200' do
send_request(environment: environment2.id) send_request(environment: environment2.id)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -44,7 +44,7 @@ describe 'metrics dashboard page' do ...@@ -44,7 +44,7 @@ describe 'metrics dashboard page' do
end end
end end
describe 'GET /:namespace/:project/-/d/:dashboard_path' do describe 'GET /:namespace/:project/-/metrics/:dashboard_path' do
let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' } let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
it 'returns 200' do it 'returns 200' do
...@@ -58,7 +58,7 @@ describe 'metrics dashboard page' do ...@@ -58,7 +58,7 @@ describe 'metrics dashboard page' do
end end
end end
describe 'GET :/namespace/:project/-/d/:dashboard_path?environment=:environment.id' do describe 'GET :/namespace/:project/-/metrics/:dashboard_path?environment=:environment.id' do
let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' } let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
it 'returns 200' do it 'returns 200' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment