Commit 25d0274e authored by Dallas Reedy's avatar Dallas Reedy Committed by Markus Koller

Clean up the BillingPlansHelper a bit

- Remove unused methods: current_plan?, plan_purchase_link,
  new_gitlab_com_trial_url
- Remove specs for unused methods: current_plan?
- Mark internally used methods as private
- Remove unused instance of RSpec::Parameterized::TableSyntax
parent 8fe298be
...@@ -9,22 +9,6 @@ module BillingPlansHelper ...@@ -9,22 +9,6 @@ module BillingPlansHelper
number_to_currency(value, unit: '$', strip_insignificant_zeros: true, format: "%u%n") number_to_currency(value, unit: '$', strip_insignificant_zeros: true, format: "%u%n")
end end
def current_plan?(plan)
plan.purchase_link&.action == 'current_plan'
end
def plan_purchase_link(href, link_text)
if href
link_to link_text, href, class: 'btn btn-success'
else
button_tag link_text, class: 'btn disabled'
end
end
def new_gitlab_com_trial_url
"#{EE::SUBSCRIPTIONS_URL}/trials/new?gl_com=true"
end
def subscription_plan_data_attributes(group, plan) def subscription_plan_data_attributes(group, plan)
return {} unless group return {} unless group
...@@ -36,26 +20,12 @@ module BillingPlansHelper ...@@ -36,26 +20,12 @@ module BillingPlansHelper
} }
end end
def plan_upgrade_url(group, plan)
return unless group && plan&.id
"#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/upgrade/#{plan.id}"
end
def use_new_purchase_flow?(namespace) def use_new_purchase_flow?(namespace)
namespace.group? && namespace.group? &&
namespace.actual_plan_name == Plan::FREE && namespace.actual_plan_name == Plan::FREE &&
Feature.enabled?(:free_group_new_purchase_flow, current_user) Feature.enabled?(:free_group_new_purchase_flow, current_user)
end end
def plan_purchase_url(group, plan)
if use_new_purchase_flow?(group)
new_subscriptions_path(plan_id: plan.id, namespace_id: group.id)
else
"#{plan.purchase_link.href}&gl_namespace_id=#{group.id}"
end
end
def show_contact_sales_button?(purchase_link_action) def show_contact_sales_button?(purchase_link_action)
experiment_enabled?(:contact_sales_btn_in_app) && experiment_enabled?(:contact_sales_btn_in_app) &&
purchase_link_action == 'upgrade' purchase_link_action == 'upgrade'
...@@ -89,4 +59,20 @@ module BillingPlansHelper ...@@ -89,4 +59,20 @@ module BillingPlansHelper
def namespace_for_user?(namespace) def namespace_for_user?(namespace)
namespace == current_user.namespace namespace == current_user.namespace
end end
private
def plan_purchase_url(group, plan)
if use_new_purchase_flow?(group)
new_subscriptions_path(plan_id: plan.id, namespace_id: group.id)
else
"#{plan.purchase_link.href}&gl_namespace_id=#{group.id}"
end
end
def plan_upgrade_url(group, plan)
return unless group && plan&.id
"#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/upgrade/#{plan.id}"
end
end end
...@@ -3,20 +3,6 @@ ...@@ -3,20 +3,6 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe BillingPlansHelper do RSpec.describe BillingPlansHelper do
describe '#current_plan?' do
it 'returns true when current_plan' do
plan = Hashie::Mash.new(purchase_link: { action: 'current_plan' })
expect(helper.current_plan?(plan)).to be_truthy
end
it 'return false when not current_plan' do
plan = Hashie::Mash.new(purchase_link: { action: 'upgrade' })
expect(helper.current_plan?(plan)).to be_falsy
end
end
describe '#subscription_plan_data_attributes' do describe '#subscription_plan_data_attributes' do
let(:customer_portal_url) { "https://customers.gitlab.com/subscriptions" } let(:customer_portal_url) { "https://customers.gitlab.com/subscriptions" }
...@@ -60,8 +46,6 @@ RSpec.describe BillingPlansHelper do ...@@ -60,8 +46,6 @@ RSpec.describe BillingPlansHelper do
end end
describe '#use_new_purchase_flow?' do describe '#use_new_purchase_flow?' do
using RSpec::Parameterized::TableSyntax
where free_group_new_purchase: [true, false], where free_group_new_purchase: [true, false],
type: ['Group', nil], type: ['Group', nil],
plan: Plan.all_plans plan: Plan.all_plans
......
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