summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Labuschagne <blabuschagne@gitlab.com>2019-01-10 12:51:21 +0200
committerBrandon Labuschagne <blabuschagne@gitlab.com>2019-01-10 12:51:21 +0200
commitfbe2c1c1043841530831be4ba85d7f5e449bbbb4 (patch)
treef8374ea81993e8a6cc38969741a0e83fec0238e7
parent61847fe147b889aed7bcfc821aa234880a8c4cae (diff)
downloadgitlab-ce-fbe2c1c1043841530831be4ba85d7f5e449bbbb4.tar.gz
Minor refactor + additional test
-rw-r--r--lib/gitlab.rb6
-rw-r--r--spec/lib/gitlab/release_blog_post_spec.rb68
2 files changed, 19 insertions, 55 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index 38bccbe5066..351c4c4e2f7 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -52,9 +52,9 @@ module Gitlab
def self.previous_release
if version_info.minor.to_i > 0
if version_info.patch.to_i > 0
- version_info.major.to_s + '.' + version_info.minor.to_i.to_s
+ "#{version_info.major}.#{version_info.minor}"
else
- version_info.major.to_s + '.' + (version_info.minor.to_i - 1).to_s
+ "#{version_info.major}.#{version_info.minor - 1}"
end
else
(version_info.major.to_i - 1).to_s
@@ -62,7 +62,7 @@ module Gitlab
end
def self.new_major_release?
- version_info.minor.to_i == 0
+ version_info.minor.to_i.zero?
end
def self.com?
diff --git a/spec/lib/gitlab/release_blog_post_spec.rb b/spec/lib/gitlab/release_blog_post_spec.rb
index 7a5dce63165..d5fd6418afe 100644
--- a/spec/lib/gitlab/release_blog_post_spec.rb
+++ b/spec/lib/gitlab/release_blog_post_spec.rb
@@ -36,97 +36,61 @@ describe Gitlab::ReleaseBlogPost do
around do |example|
release_post_url = described_class.instance.instance_variable_get(:@url)
described_class.instance.instance_variable_set(:@url, nil)
+
example.run
+
described_class.instance.instance_variable_set(:@url, release_post_url)
end
- context 'major pre release' do
- before do
+ context 'matches GitLab version to blog post url' do
+ it 'returns the correct url for major pre release' do
stub_const('Gitlab::VERSION', '11.0.0-pre')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/05/22/gitlab-10-8-released/')
end
- end
- context 'major release candidate' do
- before do
+ it 'returns the correct url for major release candidate' do
stub_const('Gitlab::VERSION', '11.0.0-rc3')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/05/22/gitlab-10-8-released/')
end
- end
- context 'major release' do
- before do
+ it 'returns the correct url for major release' do
stub_const('Gitlab::VERSION', '11.0.0')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/06/22/gitlab-11-0-released/')
end
- end
- context 'minor pre release' do
- before do
+ it 'returns the correct url for minor pre release' do
stub_const('Gitlab::VERSION', '11.2.0-pre')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/07/22/gitlab-11-1-released/')
end
- end
- context 'minor release candidate' do
- before do
+ it 'returns the correct url for minor release candidate' do
stub_const('Gitlab::VERSION', '11.2.0-rc3')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/07/22/gitlab-11-1-released/')
end
- end
- context 'minor release' do
- before do
+ it 'returns the correct url for minor release' do
stub_const('Gitlab::VERSION', '11.2.0')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
end
- end
- context 'patch pre release' do
- before do
+ it 'returns the correct url for patch pre release' do
stub_const('Gitlab::VERSION', '11.2.1-pre')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
end
- end
- context 'patch release candidate' do
- before do
+ it 'returns the correct url for patch release candidate' do
stub_const('Gitlab::VERSION', '11.2.1-rc3')
- end
-
- it 'returns the blog post url' do
expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
end
- end
- context 'patch release' do
- before do
+ it 'returns the correct url for patch release' do
stub_const('Gitlab::VERSION', '11.2.1')
+ expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
end
- it 'returns the blog post url' do
- expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
+ it 'returns nil when no blog post is matched' do
+ stub_const('Gitlab::VERSION', '9.0.0')
+ expect(subject).to be(nil)
end
end
end