summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab_spec.rb')
-rw-r--r--spec/lib/gitlab_spec.rb77
1 files changed, 77 insertions, 0 deletions
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index d63f448883b..6ac3d115bc6 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -8,6 +8,7 @@ describe Gitlab do
expect(described_class.root).to eq(Pathname.new(File.expand_path('../..', __dir__)))
end
end
+
describe '.revision' do
let(:cmd) { %W[#{described_class.config.git.bin_path} log --pretty=format:%h -n 1] }
@@ -69,6 +70,82 @@ describe Gitlab do
end
end
+ describe '.final_release?' do
+ subject { described_class.final_release? }
+
+ context 'returns the corrent boolean value' do
+ it 'is false for a pre release' do
+ stub_const('Gitlab::VERSION', '11.0.0-pre')
+
+ expect(subject).to be false
+ end
+
+ it 'is false for a release candidate' do
+ stub_const('Gitlab::VERSION', '11.0.0-rc2')
+
+ expect(subject).to be false
+ end
+
+ it 'is true for a final release' do
+ stub_const('Gitlab::VERSION', '11.0.2')
+
+ expect(subject).to be true
+ end
+ end
+ end
+
+ describe '.minor_release' do
+ subject { described_class.minor_release }
+
+ it 'returns the minor release of the full GitLab version' do
+ stub_const('Gitlab::VERSION', '11.0.1-rc3')
+
+ expect(subject).to eql '11.0'
+ end
+ end
+
+ describe '.previous_release' do
+ subject { described_class.previous_release }
+
+ context 'it should return the previous release' do
+ it 'returns the previous major version when GitLab major version is not final' do
+ stub_const('Gitlab::VERSION', '11.0.1-pre')
+
+ expect(subject).to eql '10'
+ end
+
+ it 'returns the current minor version when the GitLab patch version is RC and > 0' do
+ stub_const('Gitlab::VERSION', '11.2.1-rc3')
+
+ expect(subject).to eql '11.2'
+ end
+
+ it 'returns the previous minor version when the GitLab patch version is RC and 0' do
+ stub_const('Gitlab::VERSION', '11.2.0-rc3')
+
+ expect(subject).to eql '11.1'
+ end
+ end
+ end
+
+ describe '.new_major_release?' do
+ subject { described_class.new_major_release? }
+
+ context 'returns the corrent boolean value' do
+ it 'is true when the minor version is 0 and the patch is a pre release' do
+ stub_const('Gitlab::VERSION', '11.0.1-pre')
+
+ expect(subject).to be true
+ end
+
+ it 'is false when the minor version is above 0' do
+ stub_const('Gitlab::VERSION', '11.2.1-rc3')
+
+ expect(subject).to be false
+ end
+ end
+ end
+
describe '.com?' do
it 'is true when on GitLab.com' do
stub_config_setting(url: 'https://gitlab.com')