Commit b00ce8e5 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fix-pa-feature-flag-check' into 'master'

Fix feature flag check for productivity analytics

Closes #34786

See merge request gitlab-org/gitlab!19025
parents efd0807c 18210fdb
---
title: Fix feature flag check for productivity analytics
merge_request: 19025
author:
type: fixed
......@@ -3,9 +3,7 @@
namespace :analytics do
root to: 'analytics#index'
constraints(::Constraints::FeatureConstrainer.new(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG)) do
resource :productivity_analytics, only: :show
end
resource :productivity_analytics, only: :show, constraints: lambda { |req| Gitlab::Analytics.productivity_analytics_enabled? }
constraints(::Constraints::FeatureConstrainer.new(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG)) do
resource :cycle_analytics, only: :show
......
......@@ -3,10 +3,36 @@
require 'spec_helper'
describe 'Analytics' do
include RSpec::Rails::RequestExampleGroup
include Warden::Test::Helpers
it 'redirects to sign_in if user is not authenticated' do
expect(get('/-/analytics')).to redirect_to('/users/sign_in')
expect(get('/-/analytics')).to route_to('analytics/analytics#index')
end
context 'when user is logged in' do
let(:user) { create(:user) }
before do
login_as(user)
end
context 'productivity_analytics feature flag is enabled by default' do
it 'succeeds' do
# make sure we call this method for checking the feature availability
expect(Gitlab::Analytics).to receive(:productivity_analytics_enabled?).and_call_original
expect(get('/-/analytics/productivity_analytics')).to route_to('analytics/productivity_analytics#show')
end
end
context 'productivity_analytics feature flag is disabled' do
before do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => false)
end
it 'routes to `not_found`' do
expect(get('/-/analytics/productivity_analytics')).to route_to('application#route_not_found', unmatched_route: '-/analytics/productivity_analytics')
end
end
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