2020-10-13 02:09:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-07-26 08:10:08 -04:00
|
|
|
RSpec.describe ::Gitlab::SubscriptionPortal do
|
2021-05-18 11:10:46 -04:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
let(:env_value) { nil }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_env('CUSTOMER_PORTAL_URL', env_value)
|
2021-05-18 11:10:46 -04:00
|
|
|
end
|
2020-10-13 02:09:09 -04:00
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
describe '.default_subscriptions_url' do
|
|
|
|
where(:test, :development, :result) do
|
|
|
|
false | false | 'https://customers.gitlab.com'
|
2021-11-04 05:12:56 -04:00
|
|
|
false | true | 'https://customers.staging.gitlab.com'
|
|
|
|
true | false | 'https://customers.staging.gitlab.com'
|
2021-10-05 11:12:53 -04:00
|
|
|
end
|
2020-10-13 02:09:09 -04:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
before do
|
|
|
|
allow(Rails).to receive_message_chain(:env, :test?).and_return(test)
|
|
|
|
allow(Rails).to receive_message_chain(:env, :development?).and_return(development)
|
2020-10-13 02:09:09 -04:00
|
|
|
end
|
2021-05-07 08:10:27 -04:00
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
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-11-04 05:12:56 -04:00
|
|
|
it { is_expected.to eq('https://customers.staging.gitlab.com') }
|
2021-10-05 11:12:53 -04:00
|
|
|
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
|
|
|
|
|
2021-10-14 20:12:13 -04:00
|
|
|
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
|
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
context 'url methods' do
|
|
|
|
where(:method_name, :result) do
|
2021-11-04 05:12:56 -04:00
|
|
|
:default_subscriptions_url | 'https://customers.staging.gitlab.com'
|
|
|
|
:payment_form_url | 'https://customers.staging.gitlab.com/payment_forms/cc_validation'
|
2021-12-17 07:16:21 -05:00
|
|
|
:registration_validation_form_url | 'https://customers.staging.gitlab.com/payment_forms/cc_registration_validation'
|
2021-11-04 05:12:56 -04:00
|
|
|
: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_instance_review_url | 'https://customers.staging.gitlab.com/instance_review'
|
|
|
|
:subscriptions_gitlab_plans_url | 'https://customers.staging.gitlab.com/gitlab_plans'
|
2021-12-14 13:11:35 -05:00
|
|
|
:edit_account_url | 'https://customers.staging.gitlab.com/customers/edit'
|
2021-10-05 11:12:53 -04:00
|
|
|
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-11-04 05:12:56 -04:00
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/extra_seats") }
|
2021-10-05 11:12:53 -04:00
|
|
|
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-11-04 05:12:56 -04:00
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/upgrade/#{plan_id}") }
|
2021-10-05 11:12:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '.renew_subscription_url' do
|
|
|
|
subject { described_class.renew_subscription_url(group_id) }
|
|
|
|
|
|
|
|
let(:group_id) { 153 }
|
|
|
|
|
2021-11-04 05:12:56 -04:00
|
|
|
it { is_expected.to eq("https://customers.staging.gitlab.com/gitlab/namespaces/#{group_id}/renew") }
|
2020-10-13 02:09:09 -04:00
|
|
|
end
|
|
|
|
end
|