2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
RSpec.describe ::Gitlab::SubscriptionPortal do
|
2021-06-08 01:23:25 +05:30
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
let(:env_value) { nil }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_env('CUSTOMER_PORTAL_URL', env_value)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
describe '.default_subscriptions_url' do
|
|
|
|
where(:test, :development, :result) do
|
|
|
|
false | false | 'https://customers.gitlab.com'
|
2021-12-11 22:18:48 +05:30
|
|
|
false | true | 'https://customers.staging.gitlab.com'
|
|
|
|
true | false | 'https://customers.staging.gitlab.com'
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
before do
|
|
|
|
allow(Rails).to receive_message_chain(:env, :test?).and_return(test)
|
|
|
|
allow(Rails).to receive_message_chain(:env, :development?).and_return(development)
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
with_them do
|
|
|
|
subject { described_class.default_subscriptions_url }
|
|
|
|
|
|
|
|
it { is_expected.to eq(result) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.subscriptions_url' do
|
|
|
|
subject { described_class.subscriptions_url }
|
|
|
|
|
|
|
|
context 'when CUSTOMER_PORTAL_URL ENV is unset' do
|
2021-12-11 22:18:48 +05:30
|
|
|
it { is_expected.to eq('https://customers.staging.gitlab.com') }
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when CUSTOMER_PORTAL_URL ENV is set' do
|
|
|
|
let(:env_value) { 'https://customers.example.com' }
|
|
|
|
|
|
|
|
it { is_expected.to eq(env_value) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.subscriptions_comparison_url' do
|
|
|
|
subject { described_class.subscriptions_comparison_url }
|
|
|
|
|
|
|
|
link_match = %r{\Ahttps://about\.gitlab\.((cn/pricing/saas)|(com/pricing/gitlab-com))/feature-comparison\z}
|
|
|
|
|
|
|
|
it { is_expected.to match(link_match) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'url methods' do
|
|
|
|
where(:method_name, :result) do
|
2021-12-11 22:18:48 +05:30
|
|
|
:default_subscriptions_url | 'https://customers.staging.gitlab.com'
|
|
|
|
:payment_form_url | 'https://customers.staging.gitlab.com/payment_forms/cc_validation'
|
2022-01-26 12:08:38 +05:30
|
|
|
:registration_validation_form_url | 'https://customers.staging.gitlab.com/payment_forms/cc_registration_validation'
|
2021-12-11 22:18:48 +05:30
|
|
|
:subscriptions_graphql_url | 'https://customers.staging.gitlab.com/graphql'
|
|
|
|
:subscriptions_more_minutes_url | 'https://customers.staging.gitlab.com/buy_pipeline_minutes'
|
|
|
|
:subscriptions_more_storage_url | 'https://customers.staging.gitlab.com/buy_storage'
|
|
|
|
:subscriptions_manage_url | 'https://customers.staging.gitlab.com/subscriptions'
|
|
|
|
:subscriptions_plans_url | 'https://about.gitlab.com/pricing/'
|
|
|
|
:subscriptions_instance_review_url | 'https://customers.staging.gitlab.com/instance_review'
|
|
|
|
:subscriptions_gitlab_plans_url | 'https://customers.staging.gitlab.com/gitlab_plans'
|
2022-01-26 12:08:38 +05:30
|
|
|
:edit_account_url | 'https://customers.staging.gitlab.com/customers/edit'
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
subject { described_class.send(method_name) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(result) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.add_extra_seats_url' do
|
|
|
|
subject { described_class.add_extra_seats_url(group_id) }
|
|
|
|
|
|
|
|
let(:group_id) { 153 }
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/extra_seats") }
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe '.upgrade_subscription_url' do
|
|
|
|
subject { described_class.upgrade_subscription_url(group_id, plan_id) }
|
|
|
|
|
|
|
|
let(:group_id) { 153 }
|
|
|
|
let(:plan_id) { 5 }
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/upgrade/#{plan_id}") }
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe '.renew_subscription_url' do
|
|
|
|
subject { described_class.renew_subscription_url(group_id) }
|
|
|
|
|
|
|
|
let(:group_id) { 153 }
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/renew") }
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|