Commit c5db2d49 authored by Angelo Gulina's avatar Angelo Gulina Committed by David Kim

[Ci Minutes] [Feature flag] Add support for group actors

parent 1e4d2527
......@@ -32,11 +32,11 @@ class SubscriptionsController < ApplicationController
end
def buy_minutes
return render_404 unless Feature.enabled?(:new_route_ci_minutes_purchase, default_enabled: :yaml)
@group = find_group
return render_404 if @group.nil?
render_404 unless Feature.enabled?(:new_route_ci_minutes_purchase, @group, default_enabled: :yaml)
end
def payment_form
......
......@@ -40,7 +40,7 @@ module EE
end
def link_to_buy_additional_minutes_path(namespace)
return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if ::Feature.disabled?(:new_route_ci_minutes_purchase, default_enabled: :yaml)
return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if ::Feature.disabled?(:new_route_ci_minutes_purchase, namespace, default_enabled: :yaml)
buy_minutes_subscriptions_path(selected_group: namespace.id)
end
......
......@@ -72,7 +72,8 @@ RSpec.describe SubscriptionsController do
context 'with authenticated user' do
before do
group.add_owner(user)
stub_feature_flags(new_route_ci_minutes_purchase: true)
stub_feature_flags(new_route_ci_minutes_purchase: false)
stub_feature_flags(new_route_ci_minutes_purchase: group)
sign_in(user)
end
......
......@@ -190,6 +190,24 @@ RSpec.describe EE::NamespacesHelper do
context 'when is enabled' do
it { is_expected.to eq buy_minutes_subscriptions_path(selected_group: namespace.id) }
end
context 'when is enabled only for a specific namespace' do
let_it_be(:enabled_namespace) { create(:namespace_with_plan) }
let_it_be(:disabled_namespace) { create(:namespace_with_plan) }
before do
stub_feature_flags(new_route_ci_minutes_purchase: false)
stub_feature_flags(new_route_ci_minutes_purchase: enabled_namespace)
end
it 'returns the default purchase path for the disabled namespace' do
expect(helper.link_to_buy_additional_minutes_path(disabled_namespace)).to be EE::SUBSCRIPTIONS_MORE_MINUTES_URL
end
it 'returns GitLab purchase path for the disabled namespace' do
expect(helper.link_to_buy_additional_minutes_path(enabled_namespace)).to eq buy_minutes_subscriptions_path(selected_group: enabled_namespace.id)
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