Commit d562f206 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'vs/refactor-payment-form-specs' into 'master'

Migrate sub portal specs to parameterized syntax

See merge request gitlab-org/gitlab!61882
parents 47474d27 aeafb4a6
...@@ -2,80 +2,26 @@ ...@@ -2,80 +2,26 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ::Gitlab::SubscriptionPortal do RSpec.describe ::Gitlab::SubscriptionPortal, skip: Gitlab.jh? do
unless Gitlab.jh? using RSpec::Parameterized::TableSyntax
describe '.default_subscriptions_url' do
subject { described_class.default_subscriptions_url } where(:method_name, :test, :development, :result) do
:default_subscriptions_url | false | false | 'https://customers.gitlab.com'
context 'on non test and non dev environments' do :default_subscriptions_url | false | true | 'https://customers.stg.gitlab.com'
before do :default_subscriptions_url | true | false | 'https://customers.stg.gitlab.com'
allow(Rails).to receive_message_chain(:env, :test?).and_return(false) :payment_form_url | false | false | 'https://customers.gitlab.com/payment_forms/cc_validation'
allow(Rails).to receive_message_chain(:env, :development?).and_return(false) :payment_form_url | false | true | 'https://customers.stg.gitlab.com/payment_forms/cc_validation'
end :payment_form_url | true | false | 'https://customers.stg.gitlab.com/payment_forms/cc_validation'
end
it 'returns production subscriptions app URL' do
is_expected.to eq('https://customers.gitlab.com')
end
end
context 'on dev environment' do
before do
allow(Rails).to receive_message_chain(:env, :test?).and_return(false)
allow(Rails).to receive_message_chain(:env, :development?).and_return(true)
end
it 'returns staging subscriptions app url' do
is_expected.to eq('https://customers.stg.gitlab.com')
end
end
context 'on test environment' do with_them do
before do subject { described_class.method(method_name).call }
allow(Rails).to receive_message_chain(:env, :test?).and_return(true)
allow(Rails).to receive_message_chain(:env, :development?).and_return(false)
end
it 'returns staging subscriptions app url' do before do
is_expected.to eq('https://customers.stg.gitlab.com') allow(Rails).to receive_message_chain(:env, :test?).and_return(test)
end allow(Rails).to receive_message_chain(:env, :development?).and_return(development)
end
end end
describe '.payment_form_url' do it { is_expected.to eq(result) }
subject { described_class.payment_form_url }
context 'on non test and non dev environments' do
before do
allow(Rails).to receive_message_chain(:env, :test?).and_return(false)
allow(Rails).to receive_message_chain(:env, :development?).and_return(false)
end
it 'returns URL to production payment form' do
is_expected.to eq('https://customers.gitlab.com/payment_forms/cc_validation')
end
end
context 'on dev environment' do
before do
allow(Rails).to receive_message_chain(:env, :test?).and_return(false)
allow(Rails).to receive_message_chain(:env, :development?).and_return(true)
end
it 'returns URL to staging payment form' do
is_expected.to eq('https://customers.stg.gitlab.com/payment_forms/cc_validation')
end
end
context 'on test environment' do
before do
allow(Rails).to receive_message_chain(:env, :test?).and_return(true)
allow(Rails).to receive_message_chain(:env, :development?).and_return(false)
end
it 'returns URL to staging payment form' do
is_expected.to eq('https://customers.stg.gitlab.com/payment_forms/cc_validation')
end
end
end
end end
end end
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