Commit 37dc7e6f authored by Kerri Miller's avatar Kerri Miller

Merge branch 'vij-fix-minutes-cta-namespace' into 'master'

Fix "Buy more minutes" link destination

See merge request gitlab-org/gitlab!54080
parents 44ef875f 13ff0ad7
......@@ -26,6 +26,10 @@ module EE
show_out_of_pipeline_minutes_notification?(project, namespace)
end
def root_ancestor_namespace(project, namespace)
(project || namespace).root_ancestor
end
private
def notification_dot_acknowledged?
......
......@@ -72,5 +72,13 @@ module EE
ActionDispatch::Http::URL.path_for(path: path, params: params)
end
def usage_quotas_path(namespace, *args)
if namespace.group?
group_usage_quotas_path(namespace, *args)
else
profile_usage_quotas_path(*args)
end
end
end
end
......@@ -51,14 +51,6 @@ module EE
namespace.additional_repo_storage_by_namespace_enabled?
end
def namespace_storage_usage_link(namespace)
if namespace.group?
group_usage_quotas_path(namespace, anchor: 'storage-quota-tab')
else
profile_usage_quotas_path(anchor: 'storage-quota-tab')
end
end
def purchase_storage_url
EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
......
......@@ -3,8 +3,9 @@
- link_text = s_("CurrentUser|Buy Pipeline minutes")
- link_emoji = emoji_icon('clock9', 'aria-hidden': true)
- link_class = 'ci-minutes-emoji js-buy-pipeline-minutes-link'
- data_attributes = { 'track-event': 'click_buy_ci_minutes', 'track-label': current_user.namespace.actual_plan_name, 'track-property': 'user_dropdown' }
- path = profile_usage_quotas_path
- root_namespace = root_ancestor_namespace(project, namespace)
- data_attributes = { 'track-event': 'click_buy_ci_minutes', 'track-label': root_namespace.actual_plan_name, 'track-property': 'user_dropdown' }
- path = usage_quotas_path(root_namespace)
- content_for :buy_pipeline_with_subtext do
.gl-pb-2
......
......@@ -12,7 +12,7 @@
- style = namespace_storage_alert_style(alert_level)
- icon = namespace_storage_alert_icon(alert_level)
- purchase_link = purchase_storage_url if purchase_storage_link_enabled?(namespace)
- usage_link = namespace_storage_usage_link(root_namespace)
- usage_link = usage_quotas_path(root_namespace, anchor: 'storage-quota-tab')
- show_storage_banner_actions = purchase_link || usage_link
.gl-py-5
......
---
title: Fix buy more minutes link to wrong destination
merge_request: 54080
author:
type: fixed
......@@ -147,5 +147,23 @@ RSpec.describe EE::Ci::RunnersHelper do
it { is_expected.to be_truthy }
end
end
describe '.root_ancestor_namespace' do
subject(:root_ancestor) { helper.root_ancestor_namespace(project, namespace) }
context 'with a project' do
it 'returns the project root ancestor' do
expect(root_ancestor).to eq project.root_ancestor
end
end
context 'with only a namespace' do
let(:project) { nil }
it 'returns the namespace root ancestor' do
expect(root_ancestor).to eq namespace.root_ancestor
end
end
end
end
end
......@@ -152,4 +152,24 @@ RSpec.describe EE::GitlabRoutingHelper do
expect(subject).to eq "http://localhost/#{vulnerability.project.namespace.path}/#{vulnerability.project.name}/-/security/vulnerabilities/#{vulnerability.id}"
end
end
describe '#usage_quotas_path' do
it 'returns the group usage quota path for a group namespace' do
group = build(:group)
expect(usage_quotas_path(group)).to eq("/groups/#{group.full_path}/-/usage_quotas")
end
it 'returns the profile usage quotas path for any other namespace' do
namespace = build(:namespace)
expect(usage_quotas_path(namespace)).to eq('/-/profile/usage_quotas')
end
it 'returns the path with any args supplied' do
namespace = build(:namespace)
expect(usage_quotas_path(namespace, foo: 'bar', anchor: 'quotas-tab')).to eq('/-/profile/usage_quotas?foo=bar#quotas-tab')
end
end
end
......@@ -56,22 +56,6 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
end
end
describe '#namespace_storage_usage_link' do
subject { helper.namespace_storage_usage_link(namespace) }
context 'when namespace is a group' do
let(:namespace) { build(:group) }
it { is_expected.to eq(group_usage_quotas_path(namespace, anchor: 'storage-quota-tab')) }
end
context 'when namespace is a user' do
let(:namespace) { build(:namespace) }
it { is_expected.to eq(profile_usage_quotas_path(anchor: 'storage-quota-tab')) }
end
end
describe '#purchase_storage_url' do
subject { helper.purchase_storage_url }
......
......@@ -16,6 +16,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
allow(view).to receive(:show_buy_pipeline_minutes?).and_return(need_minutes)
allow(view).to receive(:show_pipeline_minutes_notification_dot?).and_return(show_notification_dot)
allow(view).to receive(:show_buy_pipeline_with_subtext?).and_return(show_subtext)
allow(view).to receive(:root_ancestor_namespace).and_return(user.namespace)
render
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