Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-02 21:11:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-02 21:11:52 +0300
commitd1ade10ba69cb7c232daa36625656456c32462e4 (patch)
tree70597a997a68fc63b009001480247794a60e2dd6 /spec/scripts
parent3a52eefc27143af8a2b3838a159c52484ca4bc8b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/scripts')
-rw-r--r--spec/scripts/lib/gitlab_spec.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/spec/scripts/lib/gitlab_spec.rb b/spec/scripts/lib/gitlab_spec.rb
new file mode 100644
index 00000000000..e8a01b4e03c
--- /dev/null
+++ b/spec/scripts/lib/gitlab_spec.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require_relative '../../../scripts/lib/gitlab'
+
+RSpec.describe 'scripts/lib/gitlab.rb' do
+ let(:ee_file_path) { File.expand_path('../../../ee/app/models/license.rb', __dir__) }
+
+ describe '.ee?' do
+ before do
+ stub_env('FOSS_ONLY', nil)
+ allow(File).to receive(:exist?).with(ee_file_path) { true }
+ end
+
+ it 'returns true when ee/app/models/license.rb exists' do
+ expect(Gitlab.ee?).to eq(true)
+ end
+ end
+
+ describe '.jh?' do
+ context 'when jh directory exists and EE_ONLY is not set' do
+ before do
+ stub_env('EE_ONLY', nil)
+
+ allow(Dir).to receive(:exist?).with(File.expand_path('../../../jh', __dir__)) { true }
+ end
+
+ context 'when ee/app/models/license.rb exists' do
+ before do
+ allow(File).to receive(:exist?).with(ee_file_path) { true }
+ end
+
+ context 'when FOSS_ONLY is not set' do
+ before do
+ stub_env('FOSS_ONLY', nil)
+ end
+
+ it 'returns true' do
+ expect(Gitlab.jh?).to eq(true)
+ end
+ end
+
+ context 'when FOSS_ONLY is set to 1' do
+ before do
+ stub_env('FOSS_ONLY', '1')
+ end
+
+ it 'returns false' do
+ expect(Gitlab.jh?).to eq(false)
+ end
+ end
+ end
+
+ context 'when ee/app/models/license.rb not exist' do
+ before do
+ allow(File).to receive(:exist?).with(ee_file_path) { false }
+ end
+
+ context 'when FOSS_ONLY is not set' do
+ before do
+ stub_env('FOSS_ONLY', nil)
+ end
+
+ it 'returns true' do
+ expect(Gitlab.jh?).to eq(false)
+ end
+ end
+
+ context 'when FOSS_ONLY is set to 1' do
+ before do
+ stub_env('FOSS_ONLY', '1')
+ end
+
+ it 'returns false' do
+ expect(Gitlab.jh?).to eq(false)
+ end
+ end
+ end
+ end
+ end
+end