diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 21:08:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 21:08:01 +0300 |
commit | 8e45d25f7dde6508839ffee719c0ddc2cf6b12d3 (patch) | |
tree | 9839e7fe63b36904d40995ebf519124c9a8f7681 /spec/lib/gitlab_spec.rb | |
parent | 00c78fb814d7ce00989ac04edd6cdaa3239da284 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab_spec.rb')
-rw-r--r-- | spec/lib/gitlab_spec.rb | 78 |
1 files changed, 51 insertions, 27 deletions
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb index c1d171815ba..6bf837f1d3f 100644 --- a/spec/lib/gitlab_spec.rb +++ b/spec/lib/gitlab_spec.rb @@ -146,7 +146,7 @@ describe Gitlab do describe '.ee?' do before do - stub_env('IS_GITLAB_EE', nil) # Make sure the ENV is clean + stub_env('FOSS_ONLY', nil) # Make sure the ENV is clean described_class.instance_variable_set(:@is_ee, nil) end @@ -154,42 +154,66 @@ describe Gitlab do described_class.instance_variable_set(:@is_ee, nil) end - it 'returns true when using Enterprise Edition' do - root = Pathname.new('dummy') - license_path = double(:path, exist?: true) + context 'for EE' do + before do + root = Pathname.new('dummy') + license_path = double(:path, exist?: true) - allow(described_class) - .to receive(:root) - .and_return(root) + allow(described_class) + .to receive(:root) + .and_return(root) - allow(root) - .to receive(:join) - .with('ee/app/models/license.rb') - .and_return(license_path) + allow(root) + .to receive(:join) + .with('ee/app/models/license.rb') + .and_return(license_path) + end - expect(described_class.ee?).to eq(true) - end + context 'when using FOSS_ONLY=1' do + before do + stub_env('FOSS_ONLY', '1') + end - it 'returns false when using Community Edition' do - root = double(:path) - license_path = double(:path, exists?: false) + it 'returns not to be EE' do + expect(described_class).not_to be_ee + end + end - allow(described_class) - .to receive(:root) - .and_return(Pathname.new('dummy')) + context 'when using FOSS_ONLY=0' do + before do + stub_env('FOSS_ONLY', '0') + end - allow(root) - .to receive(:join) - .with('ee/app/models/license.rb') - .and_return(license_path) + it 'returns to be EE' do + expect(described_class).to be_ee + end + end - expect(described_class.ee?).to eq(false) + context 'when using default FOSS_ONLY' do + it 'returns to be EE' do + expect(described_class).to be_ee + end + end end - it 'returns true when the IS_GITLAB_EE variable is not empty' do - stub_env('IS_GITLAB_EE', '1') + context 'for CE' do + before do + root = double(:path) + license_path = double(:path, exists?: false) - expect(described_class.ee?).to eq(true) + allow(described_class) + .to receive(:root) + .and_return(Pathname.new('dummy')) + + allow(root) + .to receive(:join) + .with('ee/app/models/license.rb') + .and_return(license_path) + end + + it 'returns not to be EE' do + expect(described_class).not_to be_ee + end end end |