Commit cbc14512 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '330987-pull-zuora-plan-id-from-customersdot-api' into 'master'

Pull Zuora plan ID from CustomersDot API

See merge request gitlab-org/gitlab!69520
parents 07259586 eb431e71
......@@ -48,14 +48,16 @@ module PaidFeatureCalloutHelper
end
def premium_subscription_path_for_group(group)
# NOTE: We are okay hard-coding the production value for the Premium 1-year
# SaaS plan ID while this is all part of an active experiment. If & when the
# experiment is deemed a success, part of the clean-up effort will be to
# pull the value directly from the CustomersDot API. Value taken from
# https://gitlab.com/gitlab-org/customers-gitlab-com/blob/7177f13c478ef623b779d6635c4a58ee650b7884/config/application.yml#L186
# Cleanup issue: https://gitlab.com/gitlab-org/gitlab/-/issues/330987
zuora_premium_plan_id = '2c92a00d76f0d5060176f2fb0a5029ff'
new_subscriptions_path(namespace_id: group.id, plan_id: zuora_premium_plan_id)
new_subscriptions_path(namespace_id: group.id, plan_id: premium_plan_id)
end
def premium_plan_id
strong_memoize(:premium_plan_id) do
plans = GitlabSubscriptions::FetchSubscriptionPlansService.new(plan: :free).execute
next unless plans
plans.find { |data| data['code'] == 'premium' }&.fetch('id', nil)
end
end
end
......@@ -11,13 +11,6 @@ module TrialStatusWidgetHelper
D14_CALLOUT_ID = 'trial_status_reminder_d14'
D3_CALLOUT_ID = 'trial_status_reminder_d3'
# NOTE: We are okay hard-coding the production value for the Ulitmate 1-year
# SaaS plan ID while this is all part of an active experiment. If & when the
# experiment is deemed a success, part of the clean-up effort will be to
# pull the value directly from the CustomersDot API. Value taken from
# https://gitlab.com/gitlab-org/customers-gitlab-com/blob/7177f13c478ef623b779d6635c4a58ee650b7884/config/application.yml#L207
ZUORA_ULTIMATE_PLAN_ID = '2c92a0ff76f0d5250176f2f8c86f305a'
def trial_status_popover_data_attrs(group)
base_attrs = trial_status_common_data_attrs(group)
base_attrs.merge(
......@@ -83,6 +76,16 @@ module TrialStatusWidgetHelper
end
def ultimate_subscription_path_for_group(group)
new_subscriptions_path(namespace_id: group.id, plan_id: ZUORA_ULTIMATE_PLAN_ID)
new_subscriptions_path(namespace_id: group.id, plan_id: ultimate_plan_id)
end
def ultimate_plan_id
strong_memoize(:ultimate_plan_id) do
plans = GitlabSubscriptions::FetchSubscriptionPlansService.new(plan: :free).execute
next unless plans
plans.find { |data| data['code'] == 'ultimate' }&.fetch('id', nil)
end
end
end
......@@ -91,6 +91,14 @@ RSpec.describe PaidFeatureCalloutHelper do
let(:subscription) { instance_double(GitlabSubscription, plan_title: 'Ultimate') }
let(:group) { instance_double(Group, id: 123, to_param: 'test-group', trial_days_remaining: 12, gitlab_subscription: subscription) }
before do
allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService, plan: :free) do |instance|
allow(instance).to receive(:execute).and_return([
{ 'code' => 'premium', 'id' => 'premium-plan-id' }
])
end
end
subject { helper.paid_feature_popover_data_attrs(group: group, feature_name: 'first feature') }
it 'returns the set of data attributes needed to bootstrap the PaidFeatureCalloutPopover component' do
......@@ -99,7 +107,7 @@ RSpec.describe PaidFeatureCalloutHelper do
days_remaining: 12,
feature_name: 'first feature',
href_compare_plans: '/groups/test-group/-/billings',
href_upgrade_to_paid: '/-/subscriptions/new?namespace_id=123&plan_id=2c92a00d76f0d5060176f2fb0a5029ff',
href_upgrade_to_paid: '/-/subscriptions/new?namespace_id=123&plan_id=premium-plan-id',
plan_name_for_trial: 'Ultimate',
plan_name_for_upgrade: 'Premium',
target_id: 'first-feature-callout'
......
......@@ -30,6 +30,11 @@ RSpec.describe TrialStatusWidgetHelper do
trial_ends_on: trial_end_date
)
stub_experiments(forcibly_show_trial_status_popover: :candidate)
allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService, plan: :free) do |instance|
allow(instance).to receive(:execute).and_return([
{ 'code' => 'ultimate', 'id' => 'ultimate-plan-id' }
])
end
end
after do
......@@ -59,7 +64,7 @@ RSpec.describe TrialStatusWidgetHelper do
expect(data_attrs).to match(
shared_expected_attrs.merge(
group_name: group.name,
purchase_href: new_subscriptions_path(namespace_id: group.id, plan_id: described_class::ZUORA_ULTIMATE_PLAN_ID),
purchase_href: new_subscriptions_path(namespace_id: group.id, plan_id: 'ultimate-plan-id'),
target_id: shared_expected_attrs[:container_id],
start_initially_shown: start_initially_shown,
trial_end_date: trial_end_date,
......
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