Commit e9ee6fa5 authored by Nick Thomas's avatar Nick Thomas

Merge branch '8831-show-plan-of-parent-group-on-subgroup-details-page' into 'master'

Resolve "Show plan of parent group on subgroup details page"

Closes #8831

See merge request gitlab-org/gitlab!20218
parents d00e35f1 96aad6d6
......@@ -142,11 +142,14 @@ module EE
def actual_plan
strong_memoize(:actual_plan) do
if parent_id
root_ancestor.actual_plan
else
subscription = find_or_create_subscription
subscription&.hosted_plan || Plan.free || Plan.default
end
end
end
def actual_limits
# We default to PlanLimits.new otherwise a lot of specs would fail
......
- namespace = local_assigns.fetch(:namespace)
- return unless Gitlab::CurrentSettings.should_check_namespace_plan? && namespace.actual_plan&.paid?
%span.plan-badge.has-tooltip{ data: { plan: namespace.actual_plan.name }, title: "#{namespace.actual_plan.title} Plan" }
%span.plan-badge.has-tooltip{ data: { plan: namespace.actual_plan_name }, title: "#{namespace.actual_plan.title} Plan" }
= custom_icon('icon_premium')
......@@ -4,7 +4,7 @@
%li
%span.light Plan:
- if namespace.actual_plan&.paid?
%strong.plan-badge.inline{ data: { plan: namespace.actual_plan.name } }
%strong.plan-badge.inline{ data: { plan: namespace.actual_plan_name } }
= custom_icon('icon_premium')
= namespace.actual_plan.title
- else
......
---
title: Resolve Show plan of root group on subgroup details page
merge_request: 20218
author:
type: added
......@@ -147,7 +147,7 @@ module EE
namespace.billable_members_count(options[:requested_hosted_plan])
end
expose :plan, if: ->(namespace, opts) { ::Ability.allowed?(opts[:current_user], :admin_namespace, namespace) } do |namespace, _|
namespace.actual_plan&.name
namespace.actual_plan_name
end
end
end
......
......@@ -668,6 +668,32 @@ describe Namespace do
expect(namespace.gitlab_subscription).to be_present
end
end
context 'when namespace is a subgroup with a parent' do
let(:subgroup) { create(:namespace, parent: namespace) }
context 'when free plan does exist' do
before do
free_plan
end
it 'does not generates a subscription' do
expect(subgroup.actual_plan).to eq(free_plan)
expect(subgroup.gitlab_subscription).not_to be_present
end
end
context 'when namespace has a subscription associated' do
before do
create(:gitlab_subscription, namespace: namespace, hosted_plan: gold_plan)
end
it 'returns the plan from the subscription' do
expect(subgroup.actual_plan).to eq(gold_plan)
expect(subgroup.gitlab_subscription).not_to be_present
end
end
end
end
end
......@@ -687,6 +713,26 @@ describe Namespace do
expect(namespace.actual_plan_name).to eq 'free'
end
end
context 'when namespace is a subgroup with a parent' do
let(:subgroup) { create(:namespace, parent: namespace) }
context 'when namespace has a subscription associated' do
before do
create(:gitlab_subscription, namespace: namespace, hosted_plan: gold_plan)
end
it 'returns an associated plan name' do
expect(subgroup.actual_plan_name).to eq 'gold'
end
end
context 'when namespace does not have subscription associated' do
it 'returns a free plan name' do
expect(subgroup.actual_plan_name).to eq 'free'
end
end
end
end
describe '#billable_members_count' do
......
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