Skip to content
Snippets Groups Projects
Commit e4ea43b2 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 390582e1
No related branches found
No related tags found
No related merge requests found
Showing
with 258 additions and 168 deletions
Loading
Loading
@@ -32,7 +32,7 @@ module Gitlab
private
 
def move(path_was, path, base_dir = nil)
base_dir = root_dir unless base_dir
base_dir ||= root_dir
from = File.join(base_dir, path_was)
to = File.join(base_dir, path)
FileUtils.mv(from, to)
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ module Gitlab
self
end
 
def to_json
def to_json(*)
{ key: key, name: name, content: content }
end
 
Loading
Loading
Loading
Loading
@@ -57,11 +57,7 @@ module SystemCheck
end
 
def should_sanitize?
if ENV['SANITIZE'] == 'true'
true
else
false
end
ENV['SANITIZE'] == 'true'
end
 
def omnibus_gitlab?
Loading
Loading
# frozen_string_literal: true
 
namespace :yarn do
desc 'Ensure Yarn is installed'
Loading
Loading
Loading
Loading
@@ -22014,9 +22014,6 @@ msgstr ""
msgid "ciReport|%{linkStartTag}Learn more about codequality reports %{linkEndTag}"
msgstr ""
 
msgid "ciReport|%{namespace} is affected by %{vulnerability}."
msgstr ""
msgid "ciReport|%{remainingPackagesCount} more"
msgstr ""
 
Loading
Loading
@@ -22075,9 +22072,6 @@ msgstr ""
msgid "ciReport|%{reportType}: Loading resulted in an error"
msgstr ""
 
msgid "ciReport|%{vulnerability} in %{featurename}"
msgstr ""
msgid "ciReport|(errors when loading results)"
msgstr ""
 
Loading
Loading
@@ -22234,15 +22228,6 @@ msgstr ""
msgid "ciReport|There was an error reverting the dismissal. Please try again."
msgstr ""
 
msgid "ciReport|Upgrade %{name} from %{version} to %{fixed}."
msgstr ""
msgid "ciReport|Upgrade %{name} to %{fixed}."
msgstr ""
msgid "ciReport|Upgrade to %{fixed}."
msgstr ""
msgid "ciReport|Used by %{packagesString}"
msgid_plural "ciReport|Used by %{packagesString}, and %{lastPackage}"
msgstr[0] ""
Loading
Loading
Loading
Loading
@@ -111,7 +111,6 @@
"raw-loader": "^3.1.0",
"sanitize-html": "^1.20.0",
"select2": "3.5.2-browserify",
"sha1": "^1.1.1",
"smooshpack": "^0.0.54",
"sortablejs": "^1.10.0",
"sql.js": "^0.4.0",
Loading
Loading
# frozen_string_literal: true
 
$: << File.expand_path(File.dirname(__FILE__))
$: << File.expand_path(__dir__)
 
Encoding.default_external = 'UTF-8'
 
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
require 'digest/sha1'
 
module QA
context 'Release', :docker, quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196047' do
context 'Release', :docker do
describe 'Git clone using a deploy key' do
before do
Flow::Login.sign_in
Loading
Loading
Loading
Loading
@@ -134,7 +134,7 @@ describe 'Admin Groups' do
end
 
describe 'add user into a group', :js do
shared_context 'adds user into a group' do
shared_examples 'adds user into a group' do
it do
visit admin_group_path(group)
 
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@ describe 'User squashes a merge request', :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:source_branch) { 'csv' }
let(:protected_source_branch) { false }
 
let!(:original_head) { project.repository.commit('master') }
 
Loading
Loading
@@ -40,7 +41,7 @@ describe 'User squashes a merge request', :js do
def accept_mr
expect(page).to have_button('Merge')
 
uncheck 'Delete source branch'
uncheck 'Delete source branch' unless protected_source_branch
click_on 'Merge'
end
 
Loading
Loading
@@ -56,14 +57,34 @@ describe 'User squashes a merge request', :js do
end
 
context 'when the MR has only one commit' do
let(:source_branch) { 'master' }
let(:target_branch) { 'branch-merged' }
let(:protected_source_branch) { true }
let(:source_sha) { project.commit(source_branch).sha }
let(:target_sha) { project.commit(target_branch).sha }
before do
merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: 'master', target_branch: 'branch-merged')
merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: source_branch, target_branch: target_branch, squash: true)
 
visit project_merge_request_path(project, merge_request)
end
 
it 'does not show the squash checkbox' do
it 'accepts the merge request without issuing a squash request', :sidekiq_inline do
expect_next_instance_of(Gitlab::GitalyClient::OperationService) do |instance|
expect(instance).not_to receive(:user_squash)
end
expect(project.repository.ancestor?(source_branch, target_branch)).to be_falsey
expect(page).not_to have_field('squash')
accept_mr
expect(page).to have_content('Merged')
latest_target_commits = project.repository.commits_between(source_sha, target_sha).map(&:raw)
expect(latest_target_commits.count).to eq(1)
expect(project.repository.ancestor?(source_branch, target_branch)).to be_truthy
end
end
 
Loading
Loading
Loading
Loading
@@ -28,210 +28,227 @@ describe ProjectsFinder, :do_not_mock_admin_mode do
let(:params) { {} }
let(:current_user) { user }
let(:project_ids_relation) { nil }
let(:finder) { described_class.new(params: params, current_user: current_user, project_ids_relation: project_ids_relation) }
let(:use_cte) { true }
let(:finder) { described_class.new(params: params.merge(use_cte: use_cte), current_user: current_user, project_ids_relation: project_ids_relation) }
 
subject { finder.execute }
 
describe 'without a user' do
let(:current_user) { nil }
shared_examples 'ProjectFinder#execute examples' do
describe 'without a user' do
let(:current_user) { nil }
 
it { is_expected.to eq([public_project]) }
end
describe 'with a user' do
describe 'without private projects' do
it { is_expected.to match_array([public_project, internal_project]) }
it { is_expected.to eq([public_project]) }
end
 
describe 'with private projects' do
before do
private_project.add_maintainer(user)
describe 'with a user' do
describe 'without private projects' do
it { is_expected.to match_array([public_project, internal_project]) }
end
 
it { is_expected.to match_array([public_project, internal_project, private_project]) }
describe 'with private projects' do
before do
private_project.add_maintainer(user)
end
it { is_expected.to match_array([public_project, internal_project, private_project]) }
end
end
end
 
describe 'with project_ids_relation' do
let(:project_ids_relation) { Project.where(id: internal_project.id) }
describe 'with project_ids_relation' do
let(:project_ids_relation) { Project.where(id: internal_project.id) }
 
it { is_expected.to eq([internal_project]) }
end
it { is_expected.to eq([internal_project]) }
end
 
describe 'with id_after' do
context 'only returns projects with a project id greater than given' do
let(:params) { { id_after: internal_project.id }}
describe 'with id_after' do
context 'only returns projects with a project id greater than given' do
let(:params) { { id_after: internal_project.id }}
 
it { is_expected.to eq([public_project]) }
it { is_expected.to eq([public_project]) }
end
end
end
 
describe 'with id_before' do
context 'only returns projects with a project id less than given' do
let(:params) { { id_before: public_project.id }}
describe 'with id_before' do
context 'only returns projects with a project id less than given' do
let(:params) { { id_before: public_project.id }}
 
it { is_expected.to eq([internal_project]) }
it { is_expected.to eq([internal_project]) }
end
end
end
 
describe 'with both id_before and id_after' do
context 'only returns projects with a project id less than given' do
let!(:projects) { create_list(:project, 5, :public) }
let(:params) { { id_after: projects.first.id, id_before: projects.last.id }}
describe 'with both id_before and id_after' do
context 'only returns projects with a project id less than given' do
let!(:projects) { create_list(:project, 5, :public) }
let(:params) { { id_after: projects.first.id, id_before: projects.last.id }}
 
it { is_expected.to contain_exactly(*projects[1..-2]) }
it { is_expected.to contain_exactly(*projects[1..-2]) }
end
end
end
 
describe 'filter by visibility_level' do
before do
private_project.add_maintainer(user)
end
describe 'filter by visibility_level' do
before do
private_project.add_maintainer(user)
end
 
context 'private' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
context 'private' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
 
it { is_expected.to eq([private_project]) }
end
it { is_expected.to eq([private_project]) }
end
 
context 'internal' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::INTERNAL } }
context 'internal' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::INTERNAL } }
 
it { is_expected.to eq([internal_project]) }
it { is_expected.to eq([internal_project]) }
end
context 'public' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
it { is_expected.to eq([public_project]) }
end
end
 
context 'public' do
let(:params) { { visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
describe 'filter by tags' do
before do
public_project.tag_list.add('foo')
public_project.save!
end
let(:params) { { tag: 'foo' } }
 
it { is_expected.to eq([public_project]) }
end
end
 
describe 'filter by tags' do
before do
public_project.tag_list.add('foo')
public_project.save!
describe 'filter by personal' do
let!(:personal_project) { create(:project, namespace: user.namespace) }
let(:params) { { personal: true } }
it { is_expected.to eq([personal_project]) }
end
 
let(:params) { { tag: 'foo' } }
describe 'filter by search' do
let(:params) { { search: 'C' } }
 
it { is_expected.to eq([public_project]) }
end
it { is_expected.to eq([public_project]) }
end
 
describe 'filter by personal' do
let!(:personal_project) { create(:project, namespace: user.namespace) }
let(:params) { { personal: true } }
describe 'filter by name for backward compatibility' do
let(:params) { { name: 'C' } }
 
it { is_expected.to eq([personal_project]) }
end
it { is_expected.to eq([public_project]) }
end
 
describe 'filter by search' do
let(:params) { { search: 'C' } }
describe 'filter by archived' do
let!(:archived_project) { create(:project, :public, :archived, name: 'E', path: 'E') }
 
it { is_expected.to eq([public_project]) }
end
context 'non_archived=true' do
let(:params) { { non_archived: true } }
 
describe 'filter by name for backward compatibility' do
let(:params) { { name: 'C' } }
it { is_expected.to match_array([public_project, internal_project]) }
end
 
it { is_expected.to eq([public_project]) }
end
context 'non_archived=false' do
let(:params) { { non_archived: false } }
 
describe 'filter by archived' do
let!(:archived_project) { create(:project, :public, :archived, name: 'E', path: 'E') }
it { is_expected.to match_array([public_project, internal_project, archived_project]) }
end
 
context 'non_archived=true' do
let(:params) { { non_archived: true } }
describe 'filter by archived only' do
let(:params) { { archived: 'only' } }
 
it { is_expected.to match_array([public_project, internal_project]) }
end
it { is_expected.to eq([archived_project]) }
end
 
context 'non_archived=false' do
let(:params) { { non_archived: false } }
describe 'filter by archived for backward compatibility' do
let(:params) { { archived: false } }
 
it { is_expected.to match_array([public_project, internal_project, archived_project]) }
it { is_expected.to match_array([public_project, internal_project]) }
end
end
 
describe 'filter by archived only' do
let(:params) { { archived: 'only' } }
describe 'filter by trending' do
let!(:trending_project) { create(:trending_project, project: public_project) }
let(:params) { { trending: true } }
 
it { is_expected.to eq([archived_project]) }
it { is_expected.to eq([public_project]) }
end
 
describe 'filter by archived for backward compatibility' do
let(:params) { { archived: false } }
describe 'filter by owned' do
let(:params) { { owned: true } }
let!(:owned_project) { create(:project, :private, namespace: current_user.namespace) }
 
it { is_expected.to match_array([public_project, internal_project]) }
it { is_expected.to eq([owned_project]) }
end
end
 
describe 'filter by trending' do
let!(:trending_project) { create(:trending_project, project: public_project) }
let(:params) { { trending: true } }
it { is_expected.to eq([public_project]) }
end
describe 'filter by non_public' do
let(:params) { { non_public: true } }
 
describe 'filter by owned' do
let(:params) { { owned: true } }
let!(:owned_project) { create(:project, :private, namespace: current_user.namespace) }
before do
private_project.add_developer(current_user)
end
 
it { is_expected.to eq([owned_project]) }
end
it { is_expected.to eq([private_project]) }
end
 
describe 'filter by non_public' do
let(:params) { { non_public: true } }
describe 'filter by starred' do
let(:params) { { starred: true } }
 
before do
private_project.add_developer(current_user)
end
before do
current_user.toggle_star(public_project)
end
 
it { is_expected.to eq([private_project]) }
end
it { is_expected.to eq([public_project]) }
 
describe 'filter by starred' do
let(:params) { { starred: true } }
it 'returns only projects the user has access to' do
current_user.toggle_star(private_project)
 
before do
current_user.toggle_star(public_project)
is_expected.to eq([public_project])
expect(subject.count).to eq(1)
expect(subject.limit(1000).count).to eq(1)
end
end
 
it { is_expected.to eq([public_project]) }
describe 'filter by without_deleted' do
let(:params) { { without_deleted: true } }
let!(:pending_delete_project) { create(:project, :public, pending_delete: true) }
 
it 'returns only projects the user has access to' do
current_user.toggle_star(private_project)
it { is_expected.to match_array([public_project, internal_project]) }
end
 
is_expected.to eq([public_project])
describe 'sorting' do
let(:params) { { sort: 'name_asc' } }
it { is_expected.to eq([internal_project, public_project]) }
end
end
 
describe 'filter by without_deleted' do
let(:params) { { without_deleted: true } }
let!(:pending_delete_project) { create(:project, :public, pending_delete: true) }
describe 'with admin user' do
let(:user) { create(:admin) }
 
it { is_expected.to match_array([public_project, internal_project]) }
end
context 'admin mode enabled' do
before do
enable_admin_mode!(current_user)
end
 
describe 'sorting' do
let(:params) { { sort: 'name_asc' } }
it { is_expected.to match_array([public_project, internal_project, private_project, shared_project]) }
end
 
it { is_expected.to eq([internal_project, public_project]) }
context 'admin mode disabled' do
it { is_expected.to match_array([public_project, internal_project]) }
end
end
end
 
describe 'with admin user' do
let(:user) { create(:admin) }
describe 'without CTE flag enabled' do
let(:use_cte) { false }
 
context 'admin mode enabled' do
before do
enable_admin_mode!(current_user)
end
it_behaves_like 'ProjectFinder#execute examples'
end
 
it { is_expected.to match_array([public_project, internal_project, private_project, shared_project]) }
end
describe 'with CTE flag enabled' do
let(:use_cte) { true }
 
context 'admin mode disabled' do
it { is_expected.to match_array([public_project, internal_project]) }
end
it_behaves_like 'ProjectFinder#execute examples'
end
end
end
Loading
Loading
@@ -23,7 +23,6 @@ export const propsData = {
emptyNoDataSvgPath: '/path/to/no-data.svg',
emptyNoDataSmallSvgPath: '/path/to/no-data-small.svg',
emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
environmentsEndpoint: '/root/hello-prometheus/-/environments.json',
currentEnvironmentName: 'production',
customMetricsAvailable: false,
customMetricsPath: '',
Loading
Loading
Loading
Loading
@@ -159,7 +159,6 @@ describe('Monitoring store actions', () => {
{
metricsEndpoint: 'additional_metrics.json',
deploymentsEndpoint: 'deployments.json',
environmentsEndpoint: 'deployments.json',
},
mockedState,
[
Loading
Loading
@@ -168,7 +167,6 @@ describe('Monitoring store actions', () => {
payload: {
metricsEndpoint: 'additional_metrics.json',
deploymentsEndpoint: 'deployments.json',
environmentsEndpoint: 'deployments.json',
},
},
],
Loading
Loading
Loading
Loading
@@ -81,13 +81,11 @@ describe('Monitoring mutations', () => {
it('should set all the endpoints', () => {
mutations[types.SET_ENDPOINTS](stateCopy, {
metricsEndpoint: 'additional_metrics.json',
environmentsEndpoint: 'environments.json',
deploymentsEndpoint: 'deployments.json',
dashboardEndpoint: 'dashboard.json',
projectPath: '/gitlab-org/gitlab-foss',
});
expect(stateCopy.metricsEndpoint).toEqual('additional_metrics.json');
expect(stateCopy.environmentsEndpoint).toEqual('environments.json');
expect(stateCopy.deploymentsEndpoint).toEqual('deployments.json');
expect(stateCopy.dashboardEndpoint).toEqual('dashboard.json');
expect(stateCopy.projectPath).toEqual('/gitlab-org/gitlab-foss');
Loading
Loading
Loading
Loading
@@ -29,7 +29,6 @@ describe EnvironmentsHelper do
'metrics-endpoint' => additional_metrics_project_environment_path(project, environment, format: :json),
'deployments-endpoint' => project_environment_deployments_path(project, environment, format: :json),
'default-branch' => 'master',
'environments-endpoint': project_environments_path(project, format: :json),
'project-path' => project_path(project),
'tags-path' => project_tags_path(project),
'has-metrics' => "#{environment.has_metrics?}",
Loading
Loading
Loading
Loading
@@ -30,7 +30,6 @@ const propsData = {
emptyNoDataSvgPath: '/path/to/no-data.svg',
emptyNoDataSmallSvgPath: '/path/to/no-data-small.svg',
emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
environmentsEndpoint: '/root/hello-prometheus/environments/35',
currentEnvironmentName: 'production',
customMetricsAvailable: false,
customMetricsPath: '',
Loading
Loading
Loading
Loading
@@ -62,7 +62,7 @@ describe Gitlab::Metrics::Dashboard::Processor do
'metric_a1', # group priority 1, panel weight 1
project_business_metric.id, # group priority 0, panel weight nil (0)
project_response_metric.id, # group priority -5, panel weight nil (0)
project_system_metric.id, # group priority -10, panel weight nil (0)
project_system_metric.id # group priority -10, panel weight nil (0)
]
actual_metrics_order = all_metrics.map { |m| m[:id] || m[:metric_id] }
 
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ describe 'Marginalia spec' do
end
end
 
class MarginaliaTestMailer < BaseMailer
class MarginaliaTestMailer < ApplicationMailer
def first_user
User.first
end
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200127090233_remove_invalid_issue_tracker_data.rb')
describe RemoveInvalidIssueTrackerData, :migration do
let(:issue_tracker_data) { table(:issue_tracker_data) }
let(:services) { table(:services) }
let(:service) { services.create(id: 1) }
let(:data) do
{
service_id: service.id,
encrypted_issues_url: 'http:url.com',
encrypted_issues_url_iv: 'somevalue',
encrypted_new_issue_url: 'http:url.com',
encrypted_new_issue_url_iv: 'somevalue',
encrypted_project_url: 'username',
encrypted_project_url_iv: 'somevalue'
}
end
let!(:valid_data) { issue_tracker_data.create(data) }
let!(:empty_data) { issue_tracker_data.create(service_id: service.id) }
let!(:invalid_issues_url) do
data[:encrypted_issues_url_iv] = nil
issue_tracker_data.create(data)
end
let!(:missing_issues_url) do
data[:encrypted_issues_url] = ''
data[:encrypted_issues_url_iv] = nil
issue_tracker_data.create(data)
end
let!(:invalid_new_isue_url) do
data[:encrypted_new_issue_url_iv] = nil
issue_tracker_data.create(data)
end
let!(:missing_new_issue_url) do
data[:encrypted_new_issue_url] = ''
issue_tracker_data.create(data)
end
let!(:invalid_project_url) do
data[:encrypted_project_url_iv] = nil
issue_tracker_data.create(data)
end
let!(:missing_project_url) do
data[:encrypted_project_url] = nil
data[:encrypted_project_url_iv] = nil
issue_tracker_data.create(data)
end
it 'removes the invalid data' do
valid_data_records = [valid_data, empty_data, missing_issues_url, missing_new_issue_url, missing_project_url]
expect { migrate! }.to change { issue_tracker_data.count }.from(8).to(5)
expect(issue_tracker_data.all).to match_array(valid_data_records)
end
end
Loading
Loading
@@ -3780,6 +3780,25 @@ describe Project do
end
end
 
describe '.wrap_authorized_projects_with_cte' do
let!(:user) { create(:user) }
let!(:private_project) do
create(:project, :private, creator: user, namespace: user.namespace)
end
let!(:public_project) { create(:project, :public) }
let(:projects) { described_class.all.public_or_visible_to_user(user) }
subject { described_class.wrap_authorized_projects_with_cte(projects) }
it 'wrapped query matches original' do
expect(subject.to_sql).to match(/^WITH "authorized_projects" AS/)
expect(subject).to match_array(projects)
end
end
describe '#pages_available?' do
let(:project) { create(:project, group: group) }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment