From ff549ec680715e4ea1daf0cee457f29dfe3b6062 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 25 Jan 2023 18:08:56 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/lib/gitlab_spec.rb | 82 +++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 60 deletions(-) (limited to 'spec/lib/gitlab_spec.rb') diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb index c44bb64a5c0..a554e0b26a8 100644 --- a/spec/lib/gitlab_spec.rb +++ b/spec/lib/gitlab_spec.rb @@ -81,10 +81,6 @@ RSpec.describe Gitlab do describe '.com?' do context 'when not simulating SaaS' do - before do - stub_env('GITLAB_SIMULATE_SAAS', '0') - end - it "is true when on #{Gitlab::Saas.com_url}" do stub_config_setting(url: Gitlab::Saas.com_url) @@ -118,17 +114,31 @@ RSpec.describe Gitlab do end end - it 'is true when GITLAB_SIMULATE_SAAS is true and in development' do - stub_rails_env('development') - stub_env('GITLAB_SIMULATE_SAAS', '1') + context 'when simulating SaaS' do + before do + stub_const('Gitlab::GITLAB_SIMULATE_SAAS', '1') + end - expect(described_class.com?).to eq true - end + it 'is false in tests' do + expect(described_class.com?).to eq false + end + + it 'is true in development' do + stub_rails_env('development') - it 'is false when GITLAB_SIMULATE_SAAS is true and in test' do - stub_env('GITLAB_SIMULATE_SAAS', '1') + expect(described_class.com?).to eq true + end - expect(described_class.com?).to eq false + # See ee/spec/lib/gitlab_spec.rb for EE-specific changes to this behavior. + context 'in a production environment' do + before do + stub_rails_env('production') + end + + it 'is false' do + expect(described_class.com?).to eq false + end + end end end @@ -236,54 +246,6 @@ RSpec.describe Gitlab do end end - describe '.simulate_com?' do - subject { described_class.simulate_com? } - - context 'when GITLAB_SIMULATE_SAAS is true' do - before do - stub_env('GITLAB_SIMULATE_SAAS', '1') - end - - it 'is false when test env' do - expect(subject).to eq false - end - - it 'is true when dev env' do - stub_rails_env('development') - - expect(subject).to eq true - end - - it 'is false when env is not dev' do - stub_rails_env('production') - - expect(subject).to eq false - end - end - - context 'when GITLAB_SIMULATE_SAAS is false' do - before do - stub_env('GITLAB_SIMULATE_SAAS', '0') - end - - it 'is false when test env' do - expect(subject).to eq false - end - - it 'is false when dev env' do - stub_rails_env('development') - - expect(subject).to eq false - end - - it 'is false when env is not dev or test' do - stub_rails_env('production') - - expect(subject).to eq false - end - end - end - describe '.dev_or_test_env?' do subject { described_class.dev_or_test_env? } -- cgit v1.2.1