Commit 4a883f36 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Always associate a actual plan with a namespace

parent 6f0bb0b3
...@@ -6,7 +6,7 @@ class Groups::BillingsController < Groups::ApplicationController ...@@ -6,7 +6,7 @@ class Groups::BillingsController < Groups::ApplicationController
def index def index
@top_most_group = @group.root_ancestor if @group.has_parent? @top_most_group = @group.root_ancestor if @group.has_parent?
current_plan = (@top_most_group || @group).actual_plan current_plan = (@top_most_group || @group).actual_plan_name
@plans_data = FetchSubscriptionPlansService.new(plan: current_plan).execute @plans_data = FetchSubscriptionPlansService.new(plan: current_plan).execute
end end
end end
...@@ -2,6 +2,8 @@ class Profiles::BillingsController < Profiles::ApplicationController ...@@ -2,6 +2,8 @@ class Profiles::BillingsController < Profiles::ApplicationController
before_action :verify_namespace_plan_check_enabled before_action :verify_namespace_plan_check_enabled
def index def index
@plans_data = FetchSubscriptionPlansService.new(plan: current_user.namespace.actual_plan).execute @plans_data = FetchSubscriptionPlansService
.new(plan: current_user.namespace.actual_plan_name)
.execute
end end
end end
- page_title "Billing" - page_title "Billing"
- if @top_most_group - if @top_most_group
- top_most_group_plan = subscription_plan_info(@plans_data, @top_most_group.actual_plan) - top_most_group_plan = subscription_plan_info(@plans_data, @top_most_group.actual_plan_name)
= render 'shared/billings/billing_plan_header', namespace: @group, plan: top_most_group_plan, parent_group: @top_most_group = render 'shared/billings/billing_plan_header', namespace: @group, plan: top_most_group_plan, parent_group: @top_most_group
- else - else
= render 'shared/billings/billing_plans', plans_data: @plans_data, namespace: @group = render 'shared/billings/billing_plans', plans_data: @plans_data, namespace: @group
- current_plan = subscription_plan_info(plans_data, namespace.actual_plan) - current_plan = subscription_plan_info(plans_data, namespace.actual_plan_name)
- if current_plan - if current_plan
= render 'shared/billings/billing_plan_header', namespace: namespace, plan: current_plan = render 'shared/billings/billing_plan_header', namespace: namespace, plan: current_plan
......
...@@ -78,8 +78,13 @@ module EE ...@@ -78,8 +78,13 @@ module EE
# The main difference between the "plan" column and this method is that "plan" # The main difference between the "plan" column and this method is that "plan"
# returns nil / "" when it has no plan. Having no plan means it's a "free" plan. # returns nil / "" when it has no plan. Having no plan means it's a "free" plan.
#
def actual_plan def actual_plan
plan&.name || FREE_PLAN self.plan || Plan.find_by(name: FREE_PLAN)
end
def actual_plan_name
actual_plan&.name || FREE_PLAN
end end
def actual_shared_runners_minutes_limit def actual_shared_runners_minutes_limit
......
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