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
path: root/spec
diff options
context:
space:
mode:
authorBrandon Labuschagne <blabuschagne@gitlab.com>2019-01-14 19:10:19 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2019-01-14 19:10:19 +0300
commitcc281afb27365adef2d24c85f83686cc8b829187 (patch)
tree0c2d33acde02760d7d45e22c0cdba8f8a8a3f2d6 /spec
parent31af7daf788f3f65d630ab4e5d8bae4bd5607807 (diff)
Resolve "Add "What's new" menu item in top navigation"
Diffstat (limited to 'spec')
-rw-r--r--spec/features/dashboard/help_spec.rb22
-rw-r--r--spec/lib/gitlab/release_blog_post_spec.rb97
-rw-r--r--spec/lib/gitlab_spec.rb77
-rw-r--r--spec/spec_helper.rb5
4 files changed, 195 insertions, 6 deletions
diff --git a/spec/features/dashboard/help_spec.rb b/spec/features/dashboard/help_spec.rb
index 68bfbf22736..fa12cecc984 100644
--- a/spec/features/dashboard/help_spec.rb
+++ b/spec/features/dashboard/help_spec.rb
@@ -5,13 +5,23 @@ RSpec.describe 'Dashboard Help' do
sign_in(create(:user))
end
- it 'renders correctly markdown' do
- visit help_page_path("administration/raketasks/maintenance")
+ context 'help dropdown' do
+ it 'shows the "What\'s new?" menu item' do
+ visit root_dashboard_path
- expect(page).to have_content('Gather information about GitLab and the system it runs on')
+ expect(page.find('.header-help .dropdown-menu')).to have_text("What's new?")
+ end
+ end
+
+ context 'documentation' do
+ it 'renders correctly markdown' do
+ visit help_page_path("administration/raketasks/maintenance")
+
+ expect(page).to have_content('Gather information about GitLab and the system it runs on')
- node = find('.documentation h2 a#user-content-check-gitlab-configuration')
- expect(node[:href]).to eq '#check-gitlab-configuration'
- expect(find(:xpath, "#{node.path}/..").text).to eq 'Check GitLab configuration'
+ node = find('.documentation h2 a#user-content-check-gitlab-configuration')
+ expect(node[:href]).to eq '#check-gitlab-configuration'
+ expect(find(:xpath, "#{node.path}/..").text).to eq 'Check GitLab configuration'
+ end
end
end
diff --git a/spec/lib/gitlab/release_blog_post_spec.rb b/spec/lib/gitlab/release_blog_post_spec.rb
new file mode 100644
index 00000000000..2c987df3767
--- /dev/null
+++ b/spec/lib/gitlab/release_blog_post_spec.rb
@@ -0,0 +1,97 @@
+require 'spec_helper'
+
+describe Gitlab::ReleaseBlogPost do
+ describe '.blog_post_url' do
+ let(:releases_xml) do
+ <<~EOS
+ <?xml version='1.0' encoding='utf-8' ?>
+ <feed xmlns='http://www.w3.org/2005/Atom'>
+ <entry>
+ <release>11.2</release>
+ <id>https://about.gitlab.com/2018/08/22/gitlab-11-2-released/</id>
+ </entry>
+ <entry>
+ <release>11.1</release>
+ <id>https://about.gitlab.com/2018/07/22/gitlab-11-1-released/</id>
+ </entry>
+ <entry>
+ <release>11.0</release>
+ <id>https://about.gitlab.com/2018/06/22/gitlab-11-0-released/</id>
+ </entry>
+ <entry>
+ <release>10.8</release>
+ <id>https://about.gitlab.com/2018/05/22/gitlab-10-8-released/</id>
+ </entry>
+ </feed>
+ EOS
+ end
+
+ subject { described_class.send(:new).blog_post_url }
+
+ before do
+ stub_request(:get, 'https://about.gitlab.com/releases.xml')
+ .to_return(status: 200, headers: { 'content-type' => ['text/xml'] }, body: releases_xml)
+ end
+
+ 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')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/05/22/gitlab-10-8-released/')
+ end
+
+ it 'returns the correct url for major release candidate' do
+ stub_const('Gitlab::VERSION', '11.0.0-rc3')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/05/22/gitlab-10-8-released/')
+ end
+
+ it 'returns the correct url for major release' do
+ stub_const('Gitlab::VERSION', '11.0.0')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/06/22/gitlab-11-0-released/')
+ end
+
+ it 'returns the correct url for minor pre release' do
+ stub_const('Gitlab::VERSION', '11.2.0-pre')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/07/22/gitlab-11-1-released/')
+ end
+
+ it 'returns the correct url for minor release candidate' do
+ stub_const('Gitlab::VERSION', '11.2.0-rc3')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/07/22/gitlab-11-1-released/')
+ end
+
+ it 'returns the correct url for minor release' do
+ stub_const('Gitlab::VERSION', '11.2.0')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
+ end
+
+ it 'returns the correct url for patch pre release' do
+ stub_const('Gitlab::VERSION', '11.2.1-pre')
+ expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
+ end
+
+ it 'returns the correct url for patch release candidate' do
+ stub_const('Gitlab::VERSION', '11.2.1-rc3')
+
+ expect(subject).to eql('https://about.gitlab.com/2018/08/22/gitlab-11-2-released/')
+ end
+
+ 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 nil when no blog post is matched' do
+ stub_const('Gitlab::VERSION', '9.0.0')
+
+ expect(subject).to be(nil)
+ end
+ end
+ end
+end
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')
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 89357056c93..ca977effcb6 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -127,6 +127,11 @@ RSpec.configure do |config|
.and_return(false)
end
+ config.before(:suite) do
+ # Set latest release blog post URL for "What's new?" link
+ Gitlab::ReleaseBlogPost.instance.instance_variable_set(:@url, 'https://about.gitlab.com')
+ end
+
config.before(:example, :request_store) do
RequestStore.begin!
end