Commit 876dc390 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 2d73f196 c98e858d
......@@ -40,7 +40,7 @@ class Import::BitbucketServerController < Import::BaseController
else
render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
end
rescue BitbucketServer::Client::ServerError => e
rescue BitbucketServer::Connection::ConnectionError => e
render json: { errors: "Unable to connect to server: #{e}" }, status: :unprocessable_entity
end
......@@ -62,7 +62,7 @@ class Import::BitbucketServerController < Import::BaseController
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include?(repo.browse_url) }
rescue BitbucketServer::Connection::ConnectionError, BitbucketServer::Client::ServerError => e
rescue BitbucketServer::Connection::ConnectionError => e
flash[:alert] = "Unable to connect to server: #{e}"
clear_session_data
redirect_to new_import_bitbucket_server_path
......
# frozen_string_literal: true
module ReleaseBlogPostHelper
def blog_post_url
Gitlab::ReleaseBlogPost.instance.blog_post_url
end
end
......@@ -2039,6 +2039,10 @@ class Project < ActiveRecord::Base
pool_repository&.unlink_repository(repository) && update_column(:pool_repository_id, nil)
end
def link_pool_repository
pool_repository&.link_repository(repository)
end
private
def merge_requests_allowing_collaboration(source_branch = nil)
......
- show_blog_link = current_user_menu?(:help) && blog_post_url.present?
%ul
- if current_user_menu?(:help)
%li
= link_to _("Help"), help_path
%li.divider
- if show_blog_link
%li
= link_to _("What's new?"), blog_post_url
%li
= link_to _("Submit feedback"), "https://about.gitlab.com/submit-feedback"
- if current_user_menu?(:help) || current_user_menu?(:settings) || current_user_menu?(:profile)
......
......@@ -23,6 +23,7 @@ class GitGarbageCollectWorker
end
task = task.to_sym
project.link_pool_repository
gitaly_call(task, project.repository.raw_repository)
# Refresh the branch cache in case garbage collection caused a ref lookup to fail
......
......@@ -5,14 +5,13 @@ module ObjectPool
include ApplicationWorker
include ObjectPoolQueue
def perform(pool_id, project_id)
pool = PoolRepository.find_by_id(pool_id)
return unless pool&.joinable?
# The use of pool id is deprecated. Keeping the argument allows old jobs to
# still be performed.
def perform(_pool_id, project_id)
project = Project.find_by_id(project_id)
return unless project
return unless project&.pool_repository&.joinable?
pool.link_repository(project.repository)
project.link_pool_repository
Projects::HousekeepingService.new(project).execute
end
......
---
title: Resolve Add What's new menu item in top navigation
merge_request: 23186
author:
type: added
---
title: Fix Bitbucket Server importer error handling
merge_request: 24343
author:
type: fixed
---
comments: false
---
# From 11.7 to 11.8
Make sure you view this update guide from the branch (version) of GitLab you would
like to install (e.g., `11-8-stable`. You can select the branch in the version
dropdown at the top left corner of GitLab (below the menu bar).
If the highest number stable branch is unclear please check the
[GitLab Blog](https://about.gitlab.com/blog/archives.html) for installation
guide links by version.
### 1. Stop server
```bash
sudo service gitlab stop
```
### 2. Backup
NOTE: If you installed GitLab from source, make sure `rsync` is installed.
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
```
### 3. Update Ruby
NOTE: Beginning in GitLab 11.0, we only support Ruby 2.4 or higher, and dropped
support for Ruby 2.3. Be sure to upgrade if necessary.
You can check which version you are running with `ruby -v`.
Download Ruby and compile it:
```bash
mkdir /tmp/ruby && cd /tmp/ruby
curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.gz
echo 'f919a9fbcdb7abecd887157b49833663c5c15fda ruby-2.5.3.tar.gz' | shasum -c - && tar xzf ruby-2.5.3.tar.gz
cd ruby-2.5.3
./configure --disable-install-rdoc
make
sudo make install
```
Install Bundler:
```bash
sudo gem install bundler --no-document
```
### 4. Update Node
NOTE: Beginning in GitLab 11.8, we only support node 8 or higher, and dropped
support for node 6. Be sure to upgrade if necessary.
GitLab utilizes [webpack](http://webpack.js.org) to compile frontend assets.
This requires a minimum version of node v8.10.0.
You can check which version you are running with `node -v`. If you are running
a version older than `v8.10.0` you will need to update to a newer version. You
can find instructions to install from community maintained packages or compile
from source at the nodejs.org website.
<https://nodejs.org/en/download/>
GitLab also requires the use of yarn `>= v1.10.0` to manage JavaScript
dependencies.
```bash
curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn
```
More information can be found on the [yarn website](https://yarnpkg.com/en/docs/install).
### 5. Update Go
NOTE: GitLab 11.4 and higher only supports Go 1.10.x and newer, and dropped support for Go
1.9.x. Be sure to upgrade your installation if necessary.
You can check which version you are running with `go version`.
Download and install Go:
```bash
# Remove former Go installation folder
sudo rm -rf /usr/local/go
curl --remote-name --progress https://dl.google.com/go/go1.10.5.linux-amd64.tar.gz
echo 'a035d9beda8341b645d3f45a1b620cf2d8fb0c5eb409be36b389c0fd384ecc3a go1.10.5.linux-amd64.tar.gz' | shasum -a256 -c - && \
sudo tar -C /usr/local -xzf go1.10.5.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
rm go1.10.5.linux-amd64.tar.gz
```
### 6. Get latest code
```bash
cd /home/git/gitlab
sudo -u git -H git fetch --all --prune
sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
sudo -u git -H git checkout -- locale
```
For GitLab Community Edition:
```bash
cd /home/git/gitlab
sudo -u git -H git checkout 11-8-stable
```
OR
For GitLab Enterprise Edition:
```bash
cd /home/git/gitlab
sudo -u git -H git checkout 11-8-stable-ee
```
### 7. Update gitlab-shell
```bash
cd /home/git/gitlab-shell
sudo -u git -H git fetch --all --tags --prune
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION)
sudo -u git -H bin/compile
```
### 8. Update gitlab-workhorse
Install and compile gitlab-workhorse. GitLab-Workhorse uses
[GNU Make](https://www.gnu.org/software/make/).
If you are not using Linux you may have to run `gmake` instead of
`make` below.
```bash
cd /home/git/gitlab-workhorse
sudo -u git -H git fetch --all --tags --prune
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_WORKHORSE_VERSION)
sudo -u git -H make
```
### 9. Update Gitaly
#### Check Gitaly configuration
Due to a bug in the `rake gitlab:gitaly:install` script your Gitaly
configuration file may contain syntax errors. The block name
`[[storages]]`, which may occur more than once in your `config.toml`
file, should be `[[storage]]` instead.
```shell
sudo -u git -H sed -i.pre-10.1 's/\[\[storages\]\]/[[storage]]/' /home/git/gitaly/config.toml
```
#### Compile Gitaly
```shell
cd /home/git/gitaly
sudo -u git -H git fetch --all --tags --prune
sudo -u git -H git checkout v$(</home/git/gitlab/GITALY_SERVER_VERSION)
sudo -u git -H make
```
### 10. Update gitlab-pages
#### Only needed if you use GitLab Pages
Install and compile gitlab-pages. GitLab-Pages uses
[GNU Make](https://www.gnu.org/software/make/).
If you are not using Linux you may have to run `gmake` instead of
`make` below.
```bash
cd /home/git/gitlab-pages
sudo -u git -H git fetch --all --tags --prune
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make
```
### 11. Update MySQL permissions
If you are using MySQL you need to grant the GitLab user the necessary
permissions on the database:
```bash
mysql -u root -p -e "GRANT TRIGGER ON \`gitlabhq_production\`.* TO 'git'@'localhost';"
```
If you use MySQL with replication, or just have MySQL configured with binary logging,
you will need to also run the following on all of your MySQL servers:
```bash
mysql -u root -p -e "SET GLOBAL log_bin_trust_function_creators = 1;"
```
You can make this setting permanent by adding it to your `my.cnf`:
```
log_bin_trust_function_creators=1
```
### 12. Update configuration files
#### New `unicorn.rb` configuration
We have made [changes](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22372) to `unicorn.rb` to allow GitLab run with both Unicorn and Puma in future.
Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/11-8-stable/config/unicorn.rb.example but with your settings.
In particular, make sure that `require_relative "/home/git/gitlab/lib/gitlab/cluster/lifecycle_events"` line exists and the `before_exec`, `before_fork`, and `after_fork` handlers are configured as shown below:
```ruby
require_relative "/home/git/gitlab/lib/gitlab/cluster/lifecycle_events"
before_exec do |server|
# Signal application hooks that we're about to restart
Gitlab::Cluster::LifecycleEvents.do_master_restart
end
before_fork do |server, worker|
# Signal application hooks that we're about to fork
Gitlab::Cluster::LifecycleEvents.do_before_fork
end
after_fork do |server, worker|
# Signal application hooks of worker start
Gitlab::Cluster::LifecycleEvents.do_worker_start
end
```
#### New configuration options for `gitlab.yml`
There might be configuration options available for [`gitlab.yml`][yaml]. View them with the command below and apply them manually to your current `gitlab.yml`:
```sh
cd /home/git/gitlab
git diff origin/11-7-stable:config/gitlab.yml.example origin/11-8-stable:config/gitlab.yml.example
```
#### Nginx configuration
Ensure you're still up-to-date with the latest NGINX configuration changes:
```sh
cd /home/git/gitlab
# For HTTPS configurations
git diff origin/11-7-stable:lib/support/nginx/gitlab-ssl origin/11-8-stable:lib/support/nginx/gitlab-ssl
# For HTTP configurations
git diff origin/11-7-stable:lib/support/nginx/gitlab origin/11-8-stable:lib/support/nginx/gitlab
```
If you are using Strict-Transport-Security in your installation to continue using it you must enable it in your Nginx
configuration as GitLab application no longer handles setting it.
If you are using Apache instead of NGINX please see the updated [Apache templates].
Also note that because Apache does not support upstreams behind Unix sockets you
will need to let gitlab-workhorse listen on a TCP port. You can do this
via [/etc/default/gitlab].
[Apache templates]: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache
[/etc/default/gitlab]: https://gitlab.com/gitlab-org/gitlab-ce/blob/11-8-stable/lib/support/init.d/gitlab.default.example#L38
#### SMTP configuration
If you're installing from source and use SMTP to deliver mail, you will need to add the following line
to config/initializers/smtp_settings.rb:
```ruby
ActionMailer::Base.delivery_method = :smtp
```
See [smtp_settings.rb.sample] as an example.
[smtp_settings.rb.sample]: https://gitlab.com/gitlab-org/gitlab-ce/blob/11-8-stable/config/initializers/smtp_settings.rb.sample#L13
#### Init script
There might be new configuration options available for [`gitlab.default.example`][gl-example]. View them with the command below and apply them manually to your current `/etc/default/gitlab`:
```sh
cd /home/git/gitlab
git diff origin/11-7-stable:lib/support/init.d/gitlab.default.example origin/11-8-stable:lib/support/init.d/gitlab.default.example
```
Ensure you're still up-to-date with the latest init script changes:
```bash
cd /home/git/gitlab
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
```
For Ubuntu 16.04.1 LTS:
```bash
sudo systemctl daemon-reload
```
### 13. Install libs, migrations, etc.
```bash
cd /home/git/gitlab
# MySQL installations (note: the line below states '--without postgres')
sudo -u git -H bundle install --without postgres development test --deployment
# PostgreSQL installations (note: the line below states '--without mysql')
sudo -u git -H bundle install --without mysql development test --deployment
# Optional: clean up old gems
sudo -u git -H bundle clean
# Run database migrations
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
# Compile GetText PO files
sudo -u git -H bundle exec rake gettext:compile RAILS_ENV=production
# Update node dependencies and recompile assets
sudo -u git -H bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
# Clean up cache
sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
```
**MySQL installations**: Run through the `MySQL strings limits` and `Tables and data conversion to utf8mb4` [tasks](../install/database_mysql.md).
### 14. Start application
```bash
sudo service gitlab start
sudo service nginx restart
```
### 15. Check application status
Check if GitLab and its environment are configured correctly:
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
```
To make sure you didn't miss anything run a more thorough check:
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
```
If all items are green, then congratulations, the upgrade is complete!
## Things went south? Revert to previous version (11.7)
### 1. Revert the code to the previous version
Follow the [upgrade guide from 11.6 to 11.7](11.6-to-11.7.md), except for the
database migration (the backup is already migrated to the previous version).
### 2. Restore from the backup
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
```
If you have more than one backup `*.tar` file(s) please add `BACKUP=timestamp_of_backup` to the command above.
[yaml]: https://gitlab.com/gitlab-org/gitlab-ce/blob/11-8-stable/config/gitlab.yml.example
[gl-example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/11-8-stable/lib/support/init.d/gitlab.default.example
......@@ -4,18 +4,6 @@ module BitbucketServer
class Client
attr_reader :connection
ServerError = Class.new(StandardError)
SERVER_ERRORS = [SocketError,
OpenSSL::SSL::SSLError,
Errno::ECONNRESET,
Errno::ECONNREFUSED,
Errno::EHOSTUNREACH,
Net::OpenTimeout,
Net::ReadTimeout,
Gitlab::HTTP::BlockedUrlError,
BitbucketServer::Connection::ConnectionError].freeze
def initialize(options = {})
@connection = Connection.new(options)
end
......@@ -64,8 +52,6 @@ module BitbucketServer
def get_collection(path, type, page_offset: 0, limit: nil)
paginator = BitbucketServer::Paginator.new(connection, Addressable::URI.escape(path), type, page_offset: page_offset, limit: limit)
BitbucketServer::Collection.new(paginator)
rescue *SERVER_ERRORS => e
raise ServerError, e
end
end
end
......@@ -7,6 +7,17 @@ module BitbucketServer
DEFAULT_API_VERSION = '1.0'
SEPARATOR = '/'
NETWORK_ERRORS = [
SocketError,
OpenSSL::SSL::SSLError,
Errno::ECONNRESET,
Errno::ECONNREFUSED,
Errno::EHOSTUNREACH,
Net::OpenTimeout,
Net::ReadTimeout,
Gitlab::HTTP::BlockedUrlError
].freeze
attr_reader :api_version, :base_uri, :username, :token
ConnectionError = Class.new(StandardError)
......@@ -27,6 +38,8 @@ module BitbucketServer
check_errors!(response)
response.parsed_response
rescue *NETWORK_ERRORS => e
raise ConnectionError, e
end
def post(path, body)
......@@ -38,6 +51,8 @@ module BitbucketServer
check_errors!(response)
response.parsed_response
rescue *NETWORK_ERRORS => e
raise ConnectionError, e
end
# We need to support two different APIs for deletion:
......@@ -55,6 +70,8 @@ module BitbucketServer
check_errors!(response)
response.parsed_response
rescue *NETWORK_ERRORS => e
raise ConnectionError, e
end
private
......
......@@ -27,12 +27,52 @@ module Gitlab
end
end
def self.version_info
Gitlab::VersionInfo.parse(Gitlab::VERSION)
end
COM_URL = 'https://gitlab.com'.freeze
APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))}
SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z}
VERSION = File.read(root.join("VERSION")).strip.freeze
INSTALLATION_TYPE = File.read(root.join("INSTALLATION_TYPE")).strip.freeze
def self.pre_release?
VERSION.include?('pre')
end
def self.final_release?
!VERSION.include?('rc') && !pre_release?
end
def self.minor_release
"#{version_info.major}.#{version_info.minor}"
end
def self.prev_minor_release
"#{version_info.major}.#{version_info.minor - 1}"
end
def self.prev_major_release
"#{version_info.major.to_i - 1}"
end
def self.new_major_release?
version_info.minor.to_i.zero?
end
def self.previous_release
if version_info.minor_version?
if version_info.patch_version?
minor_release
else
prev_minor_release
end
else
prev_major_release
end
end
def self.com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com
Gitlab.config.gitlab.url == COM_URL || gl_subdomain?
......@@ -49,12 +89,4 @@ module Gitlab
def self.dev_env_or_com?
Rails.env.development? || org? || com?
end
def self.pre_release?
VERSION.include?('pre')
end
def self.version_info
Gitlab::VersionInfo.parse(Gitlab::VERSION)
end
end
# frozen_string_literal: true
require 'singleton'
module Gitlab
class ReleaseBlogPost
include Singleton
RELEASE_RSS_URL = 'https://about.gitlab.com/releases.xml'
def blog_post_url
@url ||= fetch_blog_post_url
end
private
def fetch_blog_post_url
installed_version = Gitlab.final_release? ? Gitlab.minor_release : Gitlab.previous_release
response = Gitlab::HTTP.get(RELEASE_RSS_URL, verify: false)
return unless response.code == 200
blog_entry = find_installed_blog_entry(response, installed_version)
blog_entry['id'] if blog_entry
end
def find_installed_blog_entry(response, installed_version)
response['feed']['entry'].find do |entry|
entry['release'] == installed_version || matches_previous_release_post(entry['release'], installed_version)
end
end
def should_match_previous_release_post?
Gitlab.new_major_release? && !Gitlab.final_release?
end
def matches_previous_release_post(rss_release_version, installed_version)
should_match_previous_release_post? && rss_release_version[/\d+/] == installed_version
end
end
end
......@@ -20,6 +20,14 @@ module Gitlab
@patch = patch
end
def minor_version?
minor.to_i > 0
end
def patch_version?
patch.to_i > 0
end
def <=>(other)
return unless other.is_a? VersionInfo
return unless valid? && other.valid?
......
......@@ -78,7 +78,7 @@ describe Import::BitbucketServerController do
end
it "returns an error when the server can't be contacted" do
expect(client).to receive(:repo).with(project_key, repo_slug).and_raise(BitbucketServer::Client::ServerError)
expect(client).to receive(:repo).with(project_key, repo_slug).and_raise(::BitbucketServer::Connection::ConnectionError)
post :create, params: { project: project_key, repository: repo_slug }, format: :json
......
......@@ -5,6 +5,15 @@ RSpec.describe 'Dashboard Help' do
sign_in(create(:user))
end
context 'help dropdown' do
it 'shows the "What\'s new?" menu item' do
visit root_dashboard_path
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")
......@@ -14,4 +23,5 @@ RSpec.describe 'Dashboard Help' do
expect(node[:href]).to eq '#check-gitlab-configuration'
expect(find(:xpath, "#{node.path}/..").text).to eq 'Check GitLab configuration'
end
end
end
......@@ -17,12 +17,6 @@ describe BitbucketServer::Client do
subject.pull_requests(project, repo_slug)
end
it 'throws an exception when connection fails' do
allow(BitbucketServer::Collection).to receive(:new).and_raise(OpenSSL::SSL::SSLError)
expect { subject.pull_requests(project, repo_slug) }.to raise_error(described_class::ServerError)
end
end
describe '#activities' do
......
......@@ -26,6 +26,12 @@ describe BitbucketServer::Connection do
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
it 'throws an exception upon a network error' do
WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
end
describe '#post' do
......@@ -42,6 +48,12 @@ describe BitbucketServer::Connection do
expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
end
it 'throws an exception upon a network error' do
WebMock.stub_request(:post, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
end
end
describe '#delete' do
......@@ -63,6 +75,12 @@ describe BitbucketServer::Connection do
expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
end
it 'throws an exception upon a network error' do
WebMock.stub_request(:delete, branch_url).with(headers: headers).to_raise(OpenSSL::SSL::SSLError)
expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
end
end
end
end
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
......@@ -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')
......
......@@ -129,6 +129,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
......
......@@ -71,6 +71,17 @@ describe GitGarbageCollectWorker do
subject.perform(project.id)
end
context 'when the repository has joined a pool' do
let!(:pool) { create(:pool_repository, :ready) }
let(:project) { pool.source_project }
it 'ensures the repositories are linked' do
expect_any_instance_of(PoolRepository).to receive(:link_repository).once
subject.perform(project.id)
end
end
end
context 'when no lease can be obtained' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment