Commit d5332d4d authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'ag/open-ci-min-in-new-window' into 'master'

Open Buy Minutes in new window if targeting CDot

See merge request gitlab-org/gitlab!72578
parents e9ce05e8 7034ea6f
......@@ -39,11 +39,20 @@ module EE
current_user.can?(:admin_namespace, namespace.root_ancestor)
end
def link_to_buy_additional_minutes_path(namespace)
use_customer_dot_path = namespace.user_namespace? || ::Feature.disabled?(:new_route_ci_minutes_purchase, namespace, default_enabled: :yaml)
return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if use_customer_dot_path
def buy_additional_minutes_path(namespace)
return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if use_customers_dot_path?(namespace)
buy_minutes_subscriptions_path(selected_group: namespace.id)
end
def buy_additional_minutes_target(namespace)
use_customers_dot_path?(namespace) ? '_blank' : '_self'
end
private
def use_customers_dot_path?(namespace)
namespace.user_namespace? || ::Feature.disabled?(:new_route_ci_minutes_purchase, namespace, default_enabled: :yaml)
end
end
end
......@@ -9,7 +9,8 @@
.col-sm-6.offset-sm-6
- if ::Gitlab.com?
= link_to s_('UsageQuota|Buy additional minutes'),
link_to_buy_additional_minutes_path(namespace),
buy_additional_minutes_path(namespace),
target: buy_additional_minutes_target(namespace),
class: 'gl-button btn btn-confirm float-right',
data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' }
......
......@@ -172,8 +172,8 @@ RSpec.describe EE::NamespacesHelper do
end
end
describe '#link_to_buy_additional_minutes_path' do
subject { helper.link_to_buy_additional_minutes_path(namespace) }
describe '#buy_additional_minutes_path' do
subject { helper.buy_additional_minutes_path(namespace) }
let_it_be(:namespace) { create(:group) }
......@@ -200,11 +200,11 @@ RSpec.describe EE::NamespacesHelper do
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
expect(helper.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)
expect(helper.buy_additional_minutes_path(enabled_namespace)).to eq buy_minutes_subscriptions_path(selected_group: enabled_namespace.id)
end
end
......@@ -213,7 +213,54 @@ RSpec.describe EE::NamespacesHelper do
let_it_be(:personal_namespace) { user.namespace }
it 'returns the default purchase' do
expect(helper.link_to_buy_additional_minutes_path(personal_namespace)).to be EE::SUBSCRIPTIONS_MORE_MINUTES_URL
expect(helper.buy_additional_minutes_path(personal_namespace)).to be EE::SUBSCRIPTIONS_MORE_MINUTES_URL
end
end
end
end
describe '#buy_additional_minutes_target' do
subject { helper.buy_additional_minutes_target(namespace) }
let_it_be(:namespace) { create(:group) }
context 'new_route_ci_minutes_purchase' do
context 'when is disabled' do
before do
stub_feature_flags(new_route_ci_minutes_purchase: false)
end
it { is_expected.to be '_blank' }
end
context 'when is enabled' do
it { is_expected.to eq '_self' }
end
context 'when is enabled only for a specific namespace' do
let_it_be(:enabled_namespace) { create(:group) }
let_it_be(:disabled_namespace) { create(:group) }
before do
stub_feature_flags(new_route_ci_minutes_purchase: false)
stub_feature_flags(new_route_ci_minutes_purchase: enabled_namespace)
end
it 'returns _blank for the disabled namespace' do
expect(helper.buy_additional_minutes_target(disabled_namespace)).to be '_blank'
end
it 'returns _self for the disabled namespace' do
expect(helper.buy_additional_minutes_target(enabled_namespace)).to eq '_self'
end
end
context 'when called for a personal namespace' do
let_it_be(:user) { create(:user) }
let_it_be(:personal_namespace) { user.namespace }
it 'returns _blank' do
expect(helper.buy_additional_minutes_target(personal_namespace)).to be '_blank'
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