Commit 6f1dda13 authored by rpereira2's avatar rpereira2 Committed by Miguel Rincon

Refine controller feature flag check and specs

parent db22be51
......@@ -14,7 +14,7 @@ module Projects
end
def show
if !Feature.enabled?(:metrics_dashboard_new_panel_page) && params[:page].present?
if params[:page].present? && !Feature.enabled?(:metrics_dashboard_new_panel_page, project)
return render_404
end
......
......@@ -80,32 +80,22 @@ RSpec.describe 'metrics dashboard page' do
end
describe 'GET :/namespace/:project/-/metrics/:page' do
context 'when metrics_dashboard_new_panel_page feature flag is disabled' do
before do
stub_feature_flags(metrics_dashboard_new_panel_page: false)
end
it 'returns 200 with path param page and feature flag enabled' do
stub_feature_flags(metrics_dashboard_new_panel_page: true)
it 'returns 404 if feature flag disabled' do
# send_request(page: 'panel/new') cannot be used because it encodes '/'
get "/#{project.namespace.to_param}/#{project.to_param}/-/metrics/panel/new"
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 200 without page' do
send_request
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'returns 200 if feature flag is enabled' do
stub_feature_flags(metrics_dashboard_new_panel_page: true)
it 'returns 404 with path param page and feature flag disabled' do
stub_feature_flags(metrics_dashboard_new_panel_page: false)
# send_request(page: 'panel/new') cannot be used because it encodes '/'
get "/#{project.namespace.to_param}/#{project.to_param}/-/metrics/panel/new"
expect(response).to have_gitlab_http_status(:ok)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......
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