debian-mirror-gitlab/spec/lib/gitlab/subscription_portal_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
3.6 KiB
Ruby
Raw Normal View History

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
2022-07-23 23:45:48 +05:30
include SubscriptionPortalHelper
2021-06-08 01:23:25 +05:30
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
2022-07-23 23:45:48 +05:30
false | false | prod_customers_url
false | true | staging_customers_url
true | false | staging_customers_url
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
2022-07-23 23:45:48 +05:30
it { is_expected.to eq(staging_customers_url) }
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
2022-10-11 01:57:18 +05:30
describe 'class methods' do
2021-11-18 22:05:49 +05:30
where(:method_name, :result) do
2022-07-23 23:45:48 +05:30
:default_subscriptions_url | staging_customers_url
:payment_form_url | "#{staging_customers_url}/payment_forms/cc_validation"
:payment_validation_form_id | 'payment_method_validation'
:registration_validation_form_url | "#{staging_customers_url}/payment_forms/cc_registration_validation"
2022-10-11 01:57:18 +05:30
:registration_validation_form_id | 'cc_registration_validation'
2022-07-23 23:45:48 +05:30
:subscriptions_graphql_url | "#{staging_customers_url}/graphql"
:subscriptions_more_minutes_url | "#{staging_customers_url}/buy_pipeline_minutes"
:subscriptions_more_storage_url | "#{staging_customers_url}/buy_storage"
:subscriptions_manage_url | "#{staging_customers_url}/subscriptions"
:subscriptions_instance_review_url | "#{staging_customers_url}/instance_review"
:subscriptions_gitlab_plans_url | "#{staging_customers_url}/gitlab_plans"
:edit_account_url | "#{staging_customers_url}/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 }
2022-07-23 23:45:48 +05:30
it do
url = "#{staging_customers_url}/gitlab/namespaces/#{group_id}/extra_seats"
is_expected.to eq(url)
end
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 }
2022-07-23 23:45:48 +05:30
it do
url = "#{staging_customers_url}/gitlab/namespaces/#{group_id}/upgrade/#{plan_id}"
is_expected.to eq(url)
end
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 }
2022-07-23 23:45:48 +05:30
it do
url = "#{staging_customers_url}/gitlab/namespaces/#{group_id}/renew"
is_expected.to eq(url)
end
2021-01-03 14:25:43 +05:30
end
2022-10-11 01:57:18 +05:30
describe 'constants' do
where(:constant_name, :result) do
'REGISTRATION_VALIDATION_FORM_ID' | 'cc_registration_validation'
end
with_them do
subject { "#{described_class}::#{constant_name}".constantize }
it { is_expected.to eq(result) }
end
end
2021-01-03 14:25:43 +05:30
end