Commit 5a30e0b5 authored by Nick Thomas's avatar Nick Thomas

Merge remote-tracking branch 'upstream/master' into nt/ce-to-ee-thursday

parents 616a68b2 494d0f3f
9.1.0-ee-pre 9.1.0-pre
...@@ -52,16 +52,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -52,16 +52,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
def application_setting_params def application_setting_params
restricted_levels = params[:application_setting][:restricted_visibility_levels]
if restricted_levels.nil?
params[:application_setting][:restricted_visibility_levels] = []
else
restricted_levels.map! do |level|
level.to_i
end
end
import_sources = params[:application_setting][:import_sources] import_sources = params[:application_setting][:import_sources]
if import_sources.nil? if import_sources.nil?
......
...@@ -713,7 +713,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -713,7 +713,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def set_suggested_approvers def set_suggested_approvers
if @merge_request.requires_approve? if @merge_request.requires_approve?
@suggested_approvers = Gitlab::AuthorityAnalyzer.new( @suggested_approvers = Gitlab::AuthorityAnalyzer.new(
@merge_request @merge_request,
@merge_request.author || current_user
).calculate(@merge_request.approvals_required) ).calculate(@merge_request.approvals_required)
end end
end end
......
...@@ -262,7 +262,8 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -262,7 +262,8 @@ class ApplicationSetting < ActiveRecord::Base
elasticsearch_aws: false, elasticsearch_aws: false,
elasticsearch_aws_region: ENV['ELASTIC_REGION'] || 'us-east-1', elasticsearch_aws_region: ENV['ELASTIC_REGION'] || 'us-east-1',
usage_ping_enabled: true, usage_ping_enabled: true,
minimum_mirror_sync_time: Gitlab::Mirror::FIFTEEN minimum_mirror_sync_time: Gitlab::Mirror::FIFTEEN,
repository_size_limit: 0
} }
end end
......
...@@ -3,7 +3,7 @@ module ApplicationSettings ...@@ -3,7 +3,7 @@ module ApplicationSettings
def execute def execute
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
limit = @params.delete(:repository_size_limit) limit = @params.delete(:repository_size_limit)
@application_setting.repository_size_limit = (limit.to_i.megabytes if limit.present?) @application_setting.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
@application_setting.update(@params) @application_setting.update(@params)
end end
......
...@@ -15,7 +15,7 @@ module Groups ...@@ -15,7 +15,7 @@ module Groups
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
limit = params.delete(:repository_size_limit) limit = params.delete(:repository_size_limit)
@group.repository_size_limit = (limit.to_i.megabytes if limit.present?) @group.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
if @group.parent && !can?(current_user, :admin_group, @group.parent) if @group.parent && !can?(current_user, :admin_group, @group.parent)
@group.parent = nil @group.parent = nil
......
...@@ -16,7 +16,7 @@ module Groups ...@@ -16,7 +16,7 @@ module Groups
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
limit = @params.delete(:repository_size_limit) limit = @params.delete(:repository_size_limit)
group.repository_size_limit = (limit.to_i.megabytes if limit.present?) group.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
group.assign_attributes(params) group.assign_attributes(params)
......
...@@ -147,7 +147,7 @@ module Projects ...@@ -147,7 +147,7 @@ module Projects
def set_repository_size_limit_as_bytes def set_repository_size_limit_as_bytes
limit = params.delete(:repository_size_limit) limit = params.delete(:repository_size_limit)
@project.repository_size_limit = (limit.to_i.megabytes if limit.present?) @project.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
end end
def set_project_name_from_path def set_project_name_from_path
......
...@@ -15,7 +15,7 @@ module Projects ...@@ -15,7 +15,7 @@ module Projects
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
limit = params.delete(:repository_size_limit) limit = params.delete(:repository_size_limit)
project.repository_size_limit = (limit.to_i.megabytes if limit.present?) project.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
new_branch = params.delete(:default_branch) new_branch = params.delete(:default_branch)
new_repository_storage = params.delete(:repository_storage) new_repository_storage = params.delete(:repository_storage)
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
%button.modify-merge-commit-link.js-toggle-button{ type: "button" } %button.modify-merge-commit-link.js-toggle-button{ type: "button" }
= icon('edit') = icon('edit')
Modify commit message Modify commit message
- unless @project.merge_requests_ff_only_enabled - unless @project.merge_requests_ff_only_enabled
.js-toggle-content.hide.prepend-top-default .js-toggle-content.hide.prepend-top-default
= render 'shared/commit_message_container', params: params, = render 'shared/commit_message_container', params: params,
......
...@@ -36,7 +36,7 @@ and `secondary` as either `slave` or `standby` server (read-only). ...@@ -36,7 +36,7 @@ and `secondary` as either `slave` or `standby` server (read-only).
The following guide assumes that: The following guide assumes that:
- You are using PostgreSQL 9.2 or later which includes the - You are using PostgreSQL 9.6 or later which includes the
[`pg_basebackup` tool][pgback]. If you are using Omnibus it includes the required [`pg_basebackup` tool][pgback]. If you are using Omnibus it includes the required
PostgreSQL version for Geo. PostgreSQL version for Geo.
- You have a primary server already set up (the GitLab server you are - You have a primary server already set up (the GitLab server you are
...@@ -66,7 +66,8 @@ The following guide assumes that: ...@@ -66,7 +66,8 @@ The following guide assumes that:
listen_address = '1.2.3.4' listen_address = '1.2.3.4'
wal_level = hot_standby wal_level = hot_standby
max_wal_senders = 5 max_wal_senders = 5
checkpoint_segments = 10 min_wal_size = 80MB
max_wal_size = 1GB
wal_keep_segments = 10 wal_keep_segments = 10
hot_standby = on hot_standby = on
``` ```
...@@ -229,5 +230,5 @@ We don't support MySQL replication for GitLab Geo. ...@@ -229,5 +230,5 @@ We don't support MySQL replication for GitLab Geo.
Read the [troubleshooting document](troubleshooting.md). Read the [troubleshooting document](troubleshooting.md).
[pgback]: http://www.postgresql.org/docs/9.2/static/app-pgbasebackup.html [pgback]: http://www.postgresql.org/docs/9.6/static/app-pgbasebackup.html
[reconfigure GitLab]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure [reconfigure GitLab]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
...@@ -3,7 +3,7 @@ require 'capybara/poltergeist' ...@@ -3,7 +3,7 @@ require 'capybara/poltergeist'
require 'capybara-screenshot/spinach' require 'capybara-screenshot/spinach'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 30 : 10 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 40 : 10
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
......
...@@ -233,18 +233,6 @@ module API ...@@ -233,18 +233,6 @@ module API
.cancel(merge_request) .cancel(merge_request)
end end
desc 'List issues that will be closed on merge' do
success Entities::MRNote
end
params do
use :pagination
end
get ':id/merge_requests/:merge_request_iid/closes_issues' do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
issues = ::Kaminari.paginate_array(merge_request.closes_issues(current_user))
present paginate(issues), with: issue_entity(user_project), current_user: current_user
end
# Get the status of the merge request's approvals # Get the status of the merge request's approvals
# #
# Parameters: # Parameters:
...@@ -290,6 +278,18 @@ module API ...@@ -290,6 +278,18 @@ module API
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user
end end
desc 'List issues that will be closed on merge' do
success Entities::MRNote
end
params do
use :pagination
end
get ':id/merge_requests/:merge_request_iid/closes_issues' do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
issues = ::Kaminari.paginate_array(merge_request.closes_issues(current_user))
present paginate(issues), with: issue_entity(user_project), current_user: current_user
end
end end
end end
end end
module Gitlab module Gitlab
class AuthorityAnalyzer class AuthorityAnalyzer
COMMITS_TO_CONSIDER = 5 COMMITS_TO_CONSIDER = 25
def initialize(merge_request) def initialize(merge_request, skip_user)
@merge_request = merge_request @merge_request = merge_request
@skip_user = skip_user
@users = Hash.new(0) @users = Hash.new(0)
end end
...@@ -19,11 +20,9 @@ module Gitlab ...@@ -19,11 +20,9 @@ module Gitlab
def involved_users def involved_users
@repo = @merge_request.target_project.repository @repo = @merge_request.target_project.repository
list_of_involved_files.each do |path| @repo.commits(@merge_request.target_branch, path: list_of_involved_files, limit: COMMITS_TO_CONSIDER).each do |commit|
@repo.commits(@merge_request.target_branch, path: path, limit: COMMITS_TO_CONSIDER).each do |commit| if commit.author && commit.author != @skip_user
if commit.author && commit.author != @merge_request.author @users[commit.author] += 1
@users[commit.author] += 1
end
end end
end end
end end
......
...@@ -346,7 +346,12 @@ module Gitlab ...@@ -346,7 +346,12 @@ module Gitlab
cmd << "--after=#{options[:after].iso8601}" if options[:after] cmd << "--after=#{options[:after].iso8601}" if options[:after]
cmd << "--before=#{options[:before].iso8601}" if options[:before] cmd << "--before=#{options[:before].iso8601}" if options[:before]
cmd << sha cmd << sha
cmd += %W[-- #{options[:path]}] if options[:path].present?
# :path can be a string or an array of strings
if options[:path].present?
cmd << '--'
cmd += Array(options[:path])
end
raw_output = IO.popen(cmd) { |io| io.read } raw_output = IO.popen(cmd) { |io| io.read }
lines = offset_in_ruby ? raw_output.lines.drop(offset) : raw_output.lines lines = offset_in_ruby ? raw_output.lines.drop(offset) : raw_output.lines
......
...@@ -21,5 +21,11 @@ module Gitlab ...@@ -21,5 +21,11 @@ module Gitlab
nil nil
end end
def try_megabytes_to_bytes(size)
Integer(size).megabytes
rescue ArgumentError
size
end
end end
end end
...@@ -3,8 +3,6 @@ require 'spec_helper' ...@@ -3,8 +3,6 @@ require 'spec_helper'
describe Admin::ApplicationSettingsController do describe Admin::ApplicationSettingsController do
include StubENV include StubENV
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:user) { create(:user)} let(:user) { create(:user)}
...@@ -17,28 +15,54 @@ describe Admin::ApplicationSettingsController do ...@@ -17,28 +15,54 @@ describe Admin::ApplicationSettingsController do
sign_in(admin) sign_in(admin)
end end
context 'with valid params' do it 'updates the default_project_visibility for string value' do
subject { put :update, application_setting: { repository_size_limit: '100' } } put :update, application_setting: { default_project_visibility: "20" }
it 'redirect to application settings page' do expect(response).to redirect_to(admin_application_settings_path)
is_expected.to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PUBLIC)
end end
it 'update the restricted levels for string values' do
put :update, application_setting: { restricted_visibility_levels: %w[10 20] }
it 'set flash notice' do expect(response).to redirect_to(admin_application_settings_path)
is_expected.to set_flash[:notice].to('Application settings saved successfully') expect(ApplicationSetting.current.restricted_visibility_levels).to eq([10, 20])
end
end end
context 'with invalid params' do it 'falls back to defaults when settings are omitted' do
subject! { put :update, application_setting: { repository_size_limit: '-100' } } put :update, application_setting: {}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PRIVATE)
expect(ApplicationSetting.current.restricted_visibility_levels).to be_empty
end
it 'updates repository_size_limit' do
put :update, application_setting: { repository_size_limit: '100' }
expect(response).to redirect_to(admin_application_settings_path)
expect(response).to set_flash[:notice].to('Application settings saved successfully')
end
it 'does not accept negative repository_size_limit' do
put :update, application_setting: { repository_size_limit: '-100' }
expect(response).to render_template(:show)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end
it 'does not accept invalid repository_size_limit' do
put :update, application_setting: { repository_size_limit: 'one thousand' }
expect(response).to render_template(:show)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end
it 'render show template' do it 'does not accept empty repository_size_limit' do
is_expected.to render_template(:show) put :update, application_setting: { repository_size_limit: '' }
end
it 'assigned @application_settings has errors' do expect(response).to render_template(:show)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end
end end
end end
......
...@@ -6,7 +6,7 @@ describe Gitlab::AuthorityAnalyzer, lib: true do ...@@ -6,7 +6,7 @@ describe Gitlab::AuthorityAnalyzer, lib: true do
let(:author) { create(:user) } let(:author) { create(:user) }
let(:user_a) { create(:user) } let(:user_a) { create(:user) }
let(:user_b) { create(:user) } let(:user_b) { create(:user) }
let(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: author) } let(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
let(:files) { [double(:file, deleted_file: true, old_path: 'foo')] } let(:files) { [double(:file, deleted_file: true, old_path: 'foo')] }
let(:commits) do let(:commits) do
...@@ -19,7 +19,7 @@ describe Gitlab::AuthorityAnalyzer, lib: true do ...@@ -19,7 +19,7 @@ describe Gitlab::AuthorityAnalyzer, lib: true do
] ]
end end
let(:approvers) { Gitlab::AuthorityAnalyzer.new(merge_request).calculate(number_of_approvers) } let(:approvers) { Gitlab::AuthorityAnalyzer.new(merge_request, author).calculate(number_of_approvers) }
before do before do
merge_request.compare = double(:compare, raw_diffs: files) merge_request.compare = double(:compare, raw_diffs: files)
......
...@@ -771,8 +771,8 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -771,8 +771,8 @@ describe Gitlab::Git::Repository, seed_helper: true do
commits = repository.log(options) commits = repository.log(options)
expect(commits.size).to be > 0 expect(commits.size).to be > 0
satisfy do expect(commits).to satisfy do |commits|
commits.all? { |commit| commit.created_at >= options[:after] } commits.all? { |commit| commit.time >= options[:after] }
end end
end end
end end
...@@ -784,8 +784,27 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -784,8 +784,27 @@ describe Gitlab::Git::Repository, seed_helper: true do
commits = repository.log(options) commits = repository.log(options)
expect(commits.size).to be > 0 expect(commits.size).to be > 0
satisfy do expect(commits).to satisfy do |commits|
commits.all? { |commit| commit.created_at <= options[:before] } commits.all? { |commit| commit.time <= options[:before] }
end
end
end
context 'when multiple paths are provided' do
let(:options) { { ref: 'master', path: ['PROCESS.md', 'README.md'] } }
def commit_files(commit)
commit.diff(commit.parent_ids.first).deltas.flat_map do |delta|
[delta.old_file[:path], delta.new_file[:path]].uniq.compact
end
end
it 'only returns commits matching at least one path' do
commits = repository.log(options)
expect(commits.size).to be > 0
expect(commits).to satisfy do |commits|
commits.none? { |commit| (commit_files(commit) & options[:path]).empty? }
end end
end end
end end
......
...@@ -184,6 +184,7 @@ describe Notify do ...@@ -184,6 +184,7 @@ describe Notify do
end end
context 'for merge requests' do context 'for merge requests' do
let(:project) { create(:project, :repository) }
let(:merge_author) { create(:user) } let(:merge_author) { create(:user) }
let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) }
let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: FFaker::Lorem.sentence) } let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: FFaker::Lorem.sentence) }
...@@ -441,7 +442,7 @@ describe Notify do ...@@ -441,7 +442,7 @@ describe Notify do
end end
describe 'project was moved' do describe 'project was moved' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
subject { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") } subject { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
...@@ -567,7 +568,7 @@ describe Notify do ...@@ -567,7 +568,7 @@ describe Notify do
end end
describe 'project invitation' do describe 'project invitation' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } } let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) { invite_to_project(project, inviter: master) } let(:project_member) { invite_to_project(project, inviter: master) }
...@@ -587,7 +588,7 @@ describe Notify do ...@@ -587,7 +588,7 @@ describe Notify do
end end
describe 'project invitation accepted' do describe 'project invitation accepted' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:invited_user) { create(:user, name: 'invited user') } let(:invited_user) { create(:user, name: 'invited user') }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } } let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) do let(:project_member) do
...@@ -612,7 +613,7 @@ describe Notify do ...@@ -612,7 +613,7 @@ describe Notify do
end end
describe 'project invitation declined' do describe 'project invitation declined' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:master) { create(:user).tap { |u| project.team << [u, :master] } } let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
let(:project_member) do let(:project_member) do
invitee = invite_to_project(project, inviter: master) invitee = invite_to_project(project, inviter: master)
...@@ -676,6 +677,7 @@ describe Notify do ...@@ -676,6 +677,7 @@ describe Notify do
end end
describe 'on a commit' do describe 'on a commit' do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit } let(:commit) { project.commit }
before(:each) { allow(note).to receive(:noteable).and_return(commit) } before(:each) { allow(note).to receive(:noteable).and_return(commit) }
...@@ -743,6 +745,7 @@ describe Notify do ...@@ -743,6 +745,7 @@ describe Notify do
end end
context 'items that are noteable, emails for a note on a diff' do context 'items that are noteable, emails for a note on a diff' do
let(:project) { create(:project, :repository) }
let(:note_author) { create(:user, name: 'author_name') } let(:note_author) { create(:user, name: 'author_name') }
before :each do before :each do
...@@ -1084,6 +1087,7 @@ describe Notify do ...@@ -1084,6 +1087,7 @@ describe Notify do
end end
describe 'email on push with multiple commits' do describe 'email on push with multiple commits' do
let(:project) { create(:project, :repository) }
let(:example_site_path) { root_path } let(:example_site_path) { root_path }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) } let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) }
...@@ -1177,6 +1181,7 @@ describe Notify do ...@@ -1177,6 +1181,7 @@ describe Notify do
end end
describe 'email on push with a single commit' do describe 'email on push with a single commit' do
let(:project) { create(:project, :repository) }
let(:example_site_path) { root_path } let(:example_site_path) { root_path }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_commit.parent_id, sample_commit.id) } let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_commit.parent_id, sample_commit.id) }
...@@ -1235,7 +1240,7 @@ describe Notify do ...@@ -1235,7 +1240,7 @@ describe Notify do
end end
describe 'HTML emails setting' do describe 'HTML emails setting' do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:multipart_mail) { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") } let(:multipart_mail) { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb') require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb')
describe MigrateProcessCommitWorkerJobs do describe MigrateProcessCommitWorkerJobs do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.commit.raw.raw_commit } let(:commit) { project.commit.raw.raw_commit }
......
...@@ -5,7 +5,7 @@ describe IssuePolicy, models: true do ...@@ -5,7 +5,7 @@ describe IssuePolicy, models: true do
describe '#rules' do describe '#rules' do
context 'using a regular issue' do context 'using a regular issue' do
let(:project) { create(:project, :public) } let(:project) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:policies) { described_class.abilities(user, issue).to_set } let(:policies) { described_class.abilities(user, issue).to_set }
......
...@@ -85,7 +85,7 @@ describe ProjectPolicy, models: true do ...@@ -85,7 +85,7 @@ describe ProjectPolicy, models: true do
end end
it 'does not include the read_issue permission when the issue author is not a member of the private project' do it 'does not include the read_issue permission when the issue author is not a member of the private project' do
project = create(:project, :private) project = create(:empty_project, :private)
issue = create(:issue, project: project) issue = create(:issue, project: project)
user = issue.author user = issue.author
......
...@@ -8,7 +8,7 @@ describe AnalyticsIssueSerializer do ...@@ -8,7 +8,7 @@ describe AnalyticsIssueSerializer do
end end
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:resource) do let(:resource) do
{ {
total_time: "172802.724419", total_time: "172802.724419",
......
...@@ -8,7 +8,7 @@ describe AnalyticsMergeRequestSerializer do ...@@ -8,7 +8,7 @@ describe AnalyticsMergeRequestSerializer do
end end
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:resource) do let(:resource) do
{ {
total_time: "172802.724419", total_time: "172802.724419",
......
...@@ -6,7 +6,7 @@ describe CommitEntity do ...@@ -6,7 +6,7 @@ describe CommitEntity do
end end
let(:request) { double('request') } let(:request) { double('request') }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:commit) { project.commit } let(:commit) { project.commit }
subject { entity.as_json } subject { entity.as_json }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe EnvironmentSerializer do describe EnvironmentSerializer do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:json) do let(:json) do
described_class described_class
...@@ -11,21 +11,20 @@ describe EnvironmentSerializer do ...@@ -11,21 +11,20 @@ describe EnvironmentSerializer do
end end
context 'when there is a single object provided' do context 'when there is a single object provided' do
before do let(:project) { create(:project, :repository) }
create(:ci_build, :manual, name: 'manual1', let(:deployable) { create(:ci_build) }
pipeline: deployable.pipeline)
end
let(:deployment) do let(:deployment) do
create(:deployment, deployable: deployable, create(:deployment, deployable: deployable,
user: user, user: user,
project: project, project: project,
sha: project.commit.id) sha: project.commit.id)
end end
let(:deployable) { create(:ci_build) }
let(:resource) { deployment.environment } let(:resource) { deployment.environment }
before do
create(:ci_build, :manual, name: 'manual1', pipeline: deployable.pipeline)
end
it 'contains important elements of environment' do it 'contains important elements of environment' do
expect(json) expect(json)
.to include(:name, :external_url, :environment_path, :last_deployment) .to include(:name, :external_url, :environment_path, :last_deployment)
......
...@@ -4,7 +4,7 @@ require 'capybara/poltergeist' ...@@ -4,7 +4,7 @@ require 'capybara/poltergeist'
require 'capybara-screenshot/rspec' require 'capybara-screenshot/rspec'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 30 : 10 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 40 : 10
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
...@@ -27,6 +27,6 @@ Capybara::Screenshot.prune_strategy = :keep_last_run ...@@ -27,6 +27,6 @@ Capybara::Screenshot.prune_strategy = :keep_last_run
RSpec.configure do |config| RSpec.configure do |config|
config.before(:suite) do config.before(:suite) do
TestEnv.warm_asset_cache TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER']
end end
end end
...@@ -3,7 +3,7 @@ shared_context 'gitlab email notification' do ...@@ -3,7 +3,7 @@ shared_context 'gitlab email notification' do
let(:gitlab_sender) { Gitlab.config.gitlab.email_from } let(:gitlab_sender) { Gitlab.config.gitlab.email_from }
let(:gitlab_sender_reply_to) { Gitlab.config.gitlab.email_reply_to } let(:gitlab_sender_reply_to) { Gitlab.config.gitlab.email_reply_to }
let(:recipient) { create(:user, email: 'recipient@example.com') } let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { create(:project) } let(:project) { create(:empty_project) }
let(:new_user_address) { 'newguy@example.com' } let(:new_user_address) { 'newguy@example.com' }
before do before do
......
...@@ -172,17 +172,11 @@ module TestEnv ...@@ -172,17 +172,11 @@ module TestEnv
# Otherwise they'd be created by the first test, often timing out and # Otherwise they'd be created by the first test, often timing out and
# causing a transient test failure # causing a transient test failure
def warm_asset_cache def warm_asset_cache
return if warm_asset_cache?
return unless defined?(Capybara) return unless defined?(Capybara)
Capybara.current_session.driver.visit '/' Capybara.current_session.driver.visit '/'
end end
def warm_asset_cache?
cache = Rails.root.join(*%w(tmp cache assets test))
Dir.exist?(cache) && Dir.entries(cache).length > 2
end
private private
def factory_repo_path def factory_repo_path
......
...@@ -116,7 +116,7 @@ describe 'gitlab:app namespace rake task' do ...@@ -116,7 +116,7 @@ describe 'gitlab:app namespace rake task' do
end end
describe 'backup creation and deletion using custom_hooks' do describe 'backup creation and deletion using custom_hooks' do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user_backup_path) { "repositories/#{project.path_with_namespace}" } let(:user_backup_path) { "repositories/#{project.path_with_namespace}" }
before(:each) do before(:each) do
...@@ -224,8 +224,8 @@ describe 'gitlab:app namespace rake task' do ...@@ -224,8 +224,8 @@ describe 'gitlab:app namespace rake task' do
end end
context 'multiple repository storages' do context 'multiple repository storages' do
let(:project_a) { create(:project, repository_storage: 'default') } let(:project_a) { create(:project, :repository, repository_storage: 'default') }
let(:project_b) { create(:project, repository_storage: 'custom') } let(:project_b) { create(:project, :repository, repository_storage: 'custom') }
before do before do
FileUtils.mkdir('tmp/tests/default_storage') FileUtils.mkdir('tmp/tests/default_storage')
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/ci/builds/_build' do describe 'projects/ci/builds/_build' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) } let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'rspec 0:2', status: :pending) } let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'rspec 0:2', status: :pending) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/generic_commit_statuses/_generic_commit_status.html.haml' do describe 'projects/generic_commit_statuses/_generic_commit_status.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) } let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) } let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) }
......
require 'spec_helper' require 'spec_helper'
describe 'projects/builds/show', :view do describe 'projects/builds/show', :view do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) } let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) do let(:pipeline) do
......
...@@ -4,7 +4,7 @@ describe 'projects/commit/_commit_box.html.haml' do ...@@ -4,7 +4,7 @@ describe 'projects/commit/_commit_box.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
before do before do
assign(:project, project) assign(:project, project)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/issues/_related_branches' do describe 'projects/issues/_related_branches' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:branch) { project.repository.find_branch('feature') } let(:branch) { project.repository.find_branch('feature') }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: branch.dereferenced_target.id, ref: 'feature') } let!(:pipeline) { create(:ci_pipeline, project: project, sha: branch.dereferenced_target.id, ref: 'feature') }
......
...@@ -4,11 +4,8 @@ describe 'projects/merge_requests/show/_commits.html.haml' do ...@@ -4,11 +4,8 @@ describe 'projects/merge_requests/show/_commits.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:target_project) { create(:project) } let(:target_project) { create(:project, :repository) }
let(:source_project) { create(:project, :repository, forked_from_project: target_project) }
let(:source_project) do
create(:project, forked_from_project: target_project)
end
let(:merge_request) do let(:merge_request) do
create(:merge_request, :simple, create(:merge_request, :simple,
......
...@@ -4,8 +4,8 @@ describe 'projects/merge_requests/edit.html.haml' do ...@@ -4,8 +4,8 @@ describe 'projects/merge_requests/edit.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
......
...@@ -4,8 +4,8 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -4,8 +4,8 @@ describe 'projects/merge_requests/show.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) } let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
......
require 'spec_helper' require 'spec_helper'
describe 'projects/pipelines/_stage', :view do describe 'projects/pipelines/_stage', :view do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_pipeline, project: project) }
let(:stage) { build(:ci_stage, pipeline: pipeline) } let(:stage) { build(:ci_stage, pipeline: pipeline) }
......
...@@ -4,7 +4,7 @@ describe 'projects/pipelines/show' do ...@@ -4,7 +4,7 @@ describe 'projects/pipelines/show' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, user: user) } let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, user: user) }
before do before do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'projects/tree/show' do describe 'projects/tree/show' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
before do before do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe DeleteMergedBranchesWorker do describe DeleteMergedBranchesWorker do
subject(:worker) { described_class.new } subject(:worker) { described_class.new }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
describe "#perform" do describe "#perform" do
it "calls DeleteMergedBranchesService" do it "calls DeleteMergedBranchesService" do
......
...@@ -5,7 +5,7 @@ describe EmailsOnPushWorker do ...@@ -5,7 +5,7 @@ describe EmailsOnPushWorker do
include EmailHelpers include EmailHelpers
include EmailSpec::Matchers include EmailSpec::Matchers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:data) { Gitlab::DataBuilder::Push.build_sample(project, user) } let(:data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
let(:recipients) { user.email } let(:recipients) { user.email }
......
...@@ -3,7 +3,7 @@ require 'fileutils' ...@@ -3,7 +3,7 @@ require 'fileutils'
require 'spec_helper' require 'spec_helper'
describe GitGarbageCollectWorker do describe GitGarbageCollectWorker do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:shell) { Gitlab::Shell.new } let(:shell) { Gitlab::Shell.new }
subject { GitGarbageCollectWorker.new } subject { GitGarbageCollectWorker.new }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe GroupDestroyWorker do describe GroupDestroyWorker do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:user) { create(:admin) } let(:user) { create(:admin) }
let!(:project) { create(:project, namespace: group) } let!(:project) { create(:empty_project, namespace: group) }
subject { GroupDestroyWorker.new } subject { GroupDestroyWorker.new }
......
require 'spec_helper' require 'spec_helper'
describe PipelineMetricsWorker do describe PipelineMetricsWorker do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) } let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) }
let(:pipeline) do let(:pipeline) do
......
...@@ -11,7 +11,7 @@ describe PipelineNotificationWorker do ...@@ -11,7 +11,7 @@ describe PipelineNotificationWorker do
status: status) status: status)
end end
let(:project) { create(:project, public_builds: false) } let(:project) { create(:project, :repository, public_builds: false) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:pusher) { user } let(:pusher) { user }
let(:watcher) { pusher } let(:watcher) { pusher }
......
...@@ -4,7 +4,7 @@ describe PostReceive do ...@@ -4,7 +4,7 @@ describe PostReceive do
let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" } let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" }
let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") } let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") }
let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) } let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:key) { create(:key, user: project.owner) } let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.shell_id } let(:key_id) { key.shell_id }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe ProcessCommitWorker do describe ProcessCommitWorker do
let(:worker) { described_class.new } let(:worker) { described_class.new }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project, author: user) } let(:issue) { create(:issue, project: project, author: user) }
let(:commit) { project.commit } let(:commit) { project.commit }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe ProjectCacheWorker do describe ProjectCacheWorker do
let(:worker) { described_class.new } let(:worker) { described_class.new }
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:statistics) { project.statistics } let(:statistics) { project.statistics }
describe '#perform' do describe '#perform' do
......
require 'spec_helper' require 'spec_helper'
describe ProjectDestroyWorker do describe ProjectDestroyWorker do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:path) { project.repository.path_to_repo } let(:path) { project.repository.path_to_repo }
subject { ProjectDestroyWorker.new } subject { ProjectDestroyWorker.new }
......
...@@ -4,7 +4,7 @@ describe RepositoryCheck::BatchWorker do ...@@ -4,7 +4,7 @@ describe RepositoryCheck::BatchWorker do
subject { described_class.new } subject { described_class.new }
it 'prefers projects that have never been checked' do it 'prefers projects that have never been checked' do
projects = create_list(:project, 3, created_at: 1.week.ago) projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 4.months.ago) projects[0].update_column(:last_repository_check_at, 4.months.ago)
projects[2].update_column(:last_repository_check_at, 3.months.ago) projects[2].update_column(:last_repository_check_at, 3.months.ago)
...@@ -12,7 +12,7 @@ describe RepositoryCheck::BatchWorker do ...@@ -12,7 +12,7 @@ describe RepositoryCheck::BatchWorker do
end end
it 'sorts projects by last_repository_check_at' do it 'sorts projects by last_repository_check_at' do
projects = create_list(:project, 3, created_at: 1.week.ago) projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.months.ago) projects[0].update_column(:last_repository_check_at, 2.months.ago)
projects[1].update_column(:last_repository_check_at, 4.months.ago) projects[1].update_column(:last_repository_check_at, 4.months.ago)
projects[2].update_column(:last_repository_check_at, 3.months.ago) projects[2].update_column(:last_repository_check_at, 3.months.ago)
...@@ -21,7 +21,7 @@ describe RepositoryCheck::BatchWorker do ...@@ -21,7 +21,7 @@ describe RepositoryCheck::BatchWorker do
end end
it 'excludes projects that were checked recently' do it 'excludes projects that were checked recently' do
projects = create_list(:project, 3, created_at: 1.week.ago) projects = create_list(:empty_project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.days.ago) projects[0].update_column(:last_repository_check_at, 2.days.ago)
projects[1].update_column(:last_repository_check_at, 2.months.ago) projects[1].update_column(:last_repository_check_at, 2.months.ago)
projects[2].update_column(:last_repository_check_at, 3.days.ago) projects[2].update_column(:last_repository_check_at, 3.days.ago)
...@@ -40,7 +40,7 @@ describe RepositoryCheck::BatchWorker do ...@@ -40,7 +40,7 @@ describe RepositoryCheck::BatchWorker do
it 'skips projects created less than 24 hours ago' do it 'skips projects created less than 24 hours ago' do
project = create(:empty_project) project = create(:empty_project)
project.update_column(:created_at, 23.hours.ago) project.update_column(:created_at, 23.hours.ago)
expect(subject.perform).to eq([]) expect(subject.perform).to eq([])
end end
end end
require 'spec_helper' require 'spec_helper'
describe RepositoryForkWorker do describe RepositoryForkWorker do
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:shell) { Gitlab::Shell.new } let(:shell) { Gitlab::Shell.new }
subject { RepositoryForkWorker.new } subject { RepositoryForkWorker.new }
......
require 'spec_helper' require 'spec_helper'
describe RepositoryImportWorker do describe RepositoryImportWorker do
let(:project) { create(:project) } let(:project) { create(:empty_project) }
subject { described_class.new } subject { described_class.new }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe UpdateMergeRequestsWorker do describe UpdateMergeRequestsWorker do
include RepoHelpers include RepoHelpers
let(:project) { create(:project) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
subject { described_class.new } subject { described_class.new }
......
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