Commit 050ba3e6 authored by charlie ablett's avatar charlie ablett

Merge branch 'incubation-5mp-feature-flag-actors' into 'master'

Support `project`, `group` and `user` actors for `incubation-5mp` feature flag

See merge request gitlab-org/gitlab!83339
parents ab1dc6cb 05a00b84
......@@ -25,7 +25,11 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController
end
def feature_flag_enabled!
unless Feature.enabled?(:incubation_5mp_google_cloud)
enabled_for_user = Feature.enabled?(:incubation_5mp_google_cloud, current_user)
enabled_for_group = Feature.enabled?(:incubation_5mp_google_cloud, project.group)
enabled_for_project = Feature.enabled?(:incubation_5mp_google_cloud, project)
feature_is_enabled = enabled_for_user || enabled_for_group || enabled_for_project
unless feature_is_enabled
track_event('feature_flag_enabled!', 'access_denied', 'feature_flag_not_enabled')
access_denied!
end
......
......@@ -90,7 +90,10 @@ module Sidebars
end
def google_cloud_menu_item
feature_is_enabled = Feature.enabled?(:incubation_5mp_google_cloud, context.project)
enabled_for_user = Feature.enabled?(:incubation_5mp_google_cloud, context.current_user)
enabled_for_group = Feature.enabled?(:incubation_5mp_google_cloud, context.project.group)
enabled_for_project = Feature.enabled?(:incubation_5mp_google_cloud, context.project)
feature_is_enabled = enabled_for_user || enabled_for_group || enabled_for_project
user_has_permissions = can?(context.current_user, :admin_project_google_cloud, context.project)
unless feature_is_enabled && user_has_permissions
......
......@@ -112,6 +112,38 @@ RSpec.describe Sidebars::Projects::Menus::InfrastructureMenu do
let(:item_id) { :google_cloud }
it_behaves_like 'access rights checks'
context 'when feature flag is turned off globally' do
before do
stub_feature_flags(incubation_5mp_google_cloud: false)
end
it { is_expected.to be_nil }
context 'when feature flag is enabled for specific project' do
before do
stub_feature_flags(incubation_5mp_google_cloud: project)
end
it_behaves_like 'access rights checks'
end
context 'when feature flag is enabled for specific group' do
before do
stub_feature_flags(incubation_5mp_google_cloud: project.group)
end
it_behaves_like 'access rights checks'
end
context 'when feature flag is enabled for specific project' do
before do
stub_feature_flags(incubation_5mp_google_cloud: user)
end
it_behaves_like 'access rights checks'
end
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