Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-08-31 21:10:19 +00:00
parent 8846ca0ed6
commit 7942fe6791
12 changed files with 151 additions and 67 deletions

View file

@ -283,7 +283,7 @@ const unicodeConversion = [
[/[ÌÍÎÏĨĪĬĮİ]/g, 'I'],
[/[Ððĥħ]/g, 'h'],
[/[ÑŃŅŇʼn]/g, 'N'],
[/[ÒÓÔÕÖØŌŎŐ]/g, 'O'],
[/[ÒÓÔÕØŌŎŐ]/g, 'O'],
[/[ÙÚÛŨŪŬŮŰŲ]/g, 'U'],
[/[ÝŶŸ]/g, 'Y'],
[/[Þñþńņň]/g, 'n'],
@ -293,7 +293,7 @@ const unicodeConversion = [
[/[çćĉċč]/g, 'c'],
[/[èéêëēĕėęě]/g, 'e'],
[/[ìíîïĩīĭį]/g, 'i'],
[/[òóôõöøōŏő]/g, 'o'],
[/[òóôõøōŏő]/g, 'o'],
[/[ùúûũūŭůűų]/g, 'u'],
[/[ýÿŷ]/g, 'y'],
[/[ĎĐ]/g, 'D'],

View file

@ -63,10 +63,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
def load_projects(finder_params)
@total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute
@total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
@total_user_projects_count = ProjectsFinder.new(params: { non_public: true, without_deleted: true }, current_user: current_user).execute
@total_starred_projects_count = ProjectsFinder.new(params: { starred: true, without_deleted: true }, current_user: current_user).execute
finder_params[:use_cte] = true if use_cte_for_finder?
finder_params[:without_deleted] = true
projects = ProjectsFinder.new(params: finder_params, current_user: current_user).execute
@ -89,7 +90,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
def load_events
projects = ProjectsFinder
.new(params: params.merge(non_public: true), current_user: current_user)
.new(params: params.merge(non_public: true, without_deleted: true), current_user: current_user)
.execute
@events = EventCollection

View file

@ -24,6 +24,7 @@
# last_activity_after: datetime
# last_activity_before: datetime
# repository_storage: string
# without_deleted: boolean
#
class ProjectsFinder < UnionFinder
include CustomAttributesFilter

View file

@ -0,0 +1,5 @@
---
title: Hide projects that are pending delete from the project index
merge_request: 40035
author:
type: changed

View file

@ -104,7 +104,7 @@ You can monitor the progress in the **Admin Area > Monitoring > Background Jobs*
There is a specific queue you can watch to see how long it will take to finish:
`hashed_storage:hashed_storage_project_migrate`.
After it reaches zero, you can confirm every project has been migrated by running the commands below.
After it reaches zero, you can confirm every project has been migrated by running the commands above.
If you find it necessary, you can run this migration script again to schedule missing projects.
Any error or warning will be logged in Sidekiq's log file.
@ -153,7 +153,7 @@ sudo gitlab-rake gitlab:storage:rollback_to_legacy ID_FROM=50 ID_TO=100
You can monitor the progress in the **Admin Area > Monitoring > Background Jobs** page.
On the **Queues** tab, you can watch the `hashed_storage:hashed_storage_project_rollback` queue to see how long the process will take to finish.
After it reaches zero, you can confirm every project has been rolled back by running the commands bellow.
After it reaches zero, you can confirm every project has been rolled back by running the commands above.
If some projects weren't rolled back, you can run this rollback script again to schedule further rollbacks.
Any error or warning will be logged in Sidekiq's log file.

View file

@ -7749,10 +7749,10 @@ msgstr ""
msgid "DastProfiles|Manage profiles"
msgstr ""
msgid "DastProfiles|New Scanner Profile"
msgid "DastProfiles|New Profile"
msgstr ""
msgid "DastProfiles|New Site Profile"
msgid "DastProfiles|New Scanner Profile"
msgstr ""
msgid "DastProfiles|New scanner profile"
@ -7776,6 +7776,12 @@ msgstr ""
msgid "DastProfiles|Save profile"
msgstr ""
msgid "DastProfiles|Scanner Profile"
msgstr ""
msgid "DastProfiles|Site Profile"
msgstr ""
msgid "DastProfiles|Site Profiles"
msgstr ""

View file

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Dashboard::ProjectsController do
RSpec.describe Dashboard::ProjectsController, :aggregate_failures do
include ExternalAuthorizationServiceHelpers
let_it_be(:user) { create(:user) }
@ -15,6 +15,7 @@ RSpec.describe Dashboard::ProjectsController do
context 'user logged in' do
let_it_be(:project) { create(:project) }
let_it_be(:project2) { create(:project) }
let(:projects) { [project, project2] }
before_all do
project.add_developer(user)
@ -41,7 +42,7 @@ RSpec.describe Dashboard::ProjectsController do
get :index
expect(assigns(:projects)).to eq([project, project2])
expect(assigns(:projects)).to eq(projects)
end
context 'project sorting' do
@ -66,6 +67,20 @@ RSpec.describe Dashboard::ProjectsController do
it_behaves_like 'search and sort parameters', sort
end
end
context 'with deleted project' do
let!(:pending_delete_project) do
project.tap { |p| p.update!(pending_delete: true) }
end
it 'does not display deleted project' do
get :index
projects_result = assigns(:projects)
expect(projects_result).not_to include(pending_delete_project)
expect(projects_result).to include(project2)
end
end
end
end
@ -153,7 +168,7 @@ RSpec.describe Dashboard::ProjectsController do
project.add_developer(user)
end
it 'renders all kinds of event without error', :aggregate_failures do
it 'renders all kinds of event without error' do
get :index, format: :atom
expect(assigns(:events)).to include(design_event, wiki_page_event, issue_event)
@ -165,6 +180,21 @@ RSpec.describe Dashboard::ProjectsController do
"closed issue #{issue.to_reference}"
)
end
context 'with deleted project' do
let(:pending_deleted_project) { projects.last.tap { |p| p.update!(pending_delete: true) } }
before do
pending_deleted_project.add_developer(user)
end
it 'does not display deleted project' do
get :index, format: :atom
expect(response.body).not_to include(pending_deleted_project.full_name)
expect(response.body).to include(project.full_name)
end
end
end
end
end

View file

@ -15,7 +15,7 @@ FactoryBot.define do
end
trait :with_multibyte_characters do
size { { "utf8" => "" }.to_json.size }
size { { "utf8" => "" }.to_json.bytesize }
after(:build) do |artifact, _evaluator|
artifact.file = CarrierWaveStringFile.new_file(
file_content: { "utf8" => "" }.to_json,

View file

@ -234,10 +234,40 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do
end
describe 'filter by without_deleted' do
let(:params) { { without_deleted: true } }
let!(:pending_delete_project) { create(:project, :public, pending_delete: true) }
let_it_be(:pending_delete_project) { create(:project, :public, pending_delete: true) }
it { is_expected.to match_array([public_project, internal_project]) }
let(:params) { { without_deleted: without_deleted } }
shared_examples 'returns all projects' do
it { expect(subject).to include(public_project, internal_project, pending_delete_project) }
end
context 'when without_deleted is true' do
let(:without_deleted) { true }
it 'returns projects that are not pending_delete' do
expect(subject).not_to include(pending_delete_project)
expect(subject).to include(public_project, internal_project)
end
end
context 'when without_deleted is false' do
let(:without_deleted) { false }
it_behaves_like 'returns all projects'
end
context 'when without_deleted is nil' do
let(:without_deleted) { nil }
it_behaves_like 'returns all projects'
end
context 'when without_deleted is not present' do
let(:params) { {} }
it_behaves_like 'returns all projects'
end
end
describe 'filter by last_activity_after' do

View file

@ -218,10 +218,11 @@ describe('text_utility', () => {
it('replaces Unicode characters', () => {
expect(textUtils.convertUnicodeToAscii('Dĭd söméònê äšk fœŕ Ůnĭċődę?')).toBe(
'Did someone aesk foer Unicode?',
'Did soemeone aesk foer Unicode?',
);
expect(textUtils.convertUnicodeToAscii("Jürgen's Projekt")).toBe("Juergen's Projekt");
expect(textUtils.convertUnicodeToAscii('öäüÖÄÜ')).toBe('oeaeueOeAeUe');
});
});

View file

@ -69,7 +69,7 @@ RSpec.describe Ci::PipelineArtifact, type: :model do
let(:coverage_report_multibyte) { create(:ci_pipeline_artifact, :with_multibyte_characters) }
it 'sets the size in bytesize' do
expect(coverage_report_multibyte.size).to eq(12)
expect(coverage_report_multibyte.size).to eq(14)
end
end
end

View file

@ -2,13 +2,16 @@
require 'spec_helper'
RSpec.describe MergeRequest do
RSpec.describe MergeRequest, factory_default: :keep do
include RepoHelpers
include ProjectForksHelper
include ReactiveCachingHelpers
using RSpec::Parameterized::TableSyntax
let_it_be(:namespace) { create_default(:namespace) }
let_it_be(:project, refind: true) { create_default(:project, :repository) }
subject { create(:merge_request) }
describe 'associations' do
@ -360,7 +363,7 @@ RSpec.describe MergeRequest do
it 'returns merge requests that match the given merge commit' do
note = create(:track_mr_picking_note, commit_id: '456abc')
create(:track_mr_picking_note, commit_id: '456def')
create(:track_mr_picking_note, project: create(:project), commit_id: '456def')
expect(described_class.by_cherry_pick_sha('456abc')).to eq([note.noteable])
end
@ -832,7 +835,7 @@ RSpec.describe MergeRequest do
end
context 'with commit diff note' do
let(:other_merge_request) { create(:merge_request) }
let(:other_merge_request) { create(:merge_request, source_project: create(:project, :repository)) }
let!(:diff_note) do
create(:diff_note_on_commit, project: merge_request.project)
@ -1031,6 +1034,8 @@ RSpec.describe MergeRequest do
end
describe '#closes_issues' do
let(:project) { create(:project) }
let(:issue0) { create :issue, project: subject.project }
let(:issue1) { create :issue, project: subject.project }
@ -1038,6 +1043,8 @@ RSpec.describe MergeRequest do
let(:commit1) { double('commit1', safe_message: "Fixes #{issue0.to_reference}") }
let(:commit2) { double('commit2', safe_message: "Fixes #{issue1.to_reference}") }
subject { create(:merge_request, source_project: project) }
before do
subject.project.add_developer(subject.author)
allow(subject).to receive(:commits).and_return([commit0, commit1, commit2])
@ -1088,6 +1095,8 @@ RSpec.describe MergeRequest do
end
context 'when the project has an external issue tracker' do
subject { create(:merge_request, source_project: create(:project, :repository)) }
before do
subject.project.add_developer(subject.author)
commit = double(:commit, safe_message: 'Fixes TEST-3')
@ -1254,7 +1263,8 @@ RSpec.describe MergeRequest do
end
describe "#source_branch_exists?" do
let(:merge_request) { subject }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:repository) { merge_request.source_project.repository }
context 'when the source project is set' do
@ -1730,16 +1740,14 @@ RSpec.describe MergeRequest do
describe '#has_test_reports?' do
subject { merge_request.has_test_reports? }
let(:project) { create(:project, :repository) }
context 'when head pipeline has test reports' do
let(:merge_request) { create(:merge_request, :with_test_reports, source_project: project) }
let(:merge_request) { create(:merge_request, :with_test_reports) }
it { is_expected.to be_truthy }
end
context 'when head pipeline does not have test reports' do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request) }
it { is_expected.to be_falsey }
end
@ -1748,16 +1756,14 @@ RSpec.describe MergeRequest do
describe '#has_accessibility_reports?' do
subject { merge_request.has_accessibility_reports? }
let(:project) { create(:project, :repository) }
context 'when head pipeline has an accessibility reports' do
let(:merge_request) { create(:merge_request, :with_accessibility_reports, source_project: project) }
let(:merge_request) { create(:merge_request, :with_accessibility_reports) }
it { is_expected.to be_truthy }
end
context 'when head pipeline does not have accessibility reports' do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request) }
it { is_expected.to be_falsey }
end
@ -1766,27 +1772,23 @@ RSpec.describe MergeRequest do
describe '#has_coverage_reports?' do
subject { merge_request.has_coverage_reports? }
let(:project) { create(:project, :repository) }
context 'when head pipeline has coverage reports' do
let(:merge_request) { create(:merge_request, :with_coverage_reports, source_project: project) }
let(:merge_request) { create(:merge_request, :with_coverage_reports) }
it { is_expected.to be_truthy }
end
context 'when head pipeline does not have coverage reports' do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request) }
it { is_expected.to be_falsey }
end
end
describe '#has_terraform_reports?' do
let_it_be(:project) { create(:project, :repository) }
context 'when head pipeline has terraform reports' do
it 'returns true' do
merge_request = create(:merge_request, :with_terraform_reports, source_project: project)
merge_request = create(:merge_request, :with_terraform_reports)
expect(merge_request.has_terraform_reports?).to be_truthy
end
@ -1794,7 +1796,7 @@ RSpec.describe MergeRequest do
context 'when head pipeline does not have terraform reports' do
it 'returns false' do
merge_request = create(:merge_request, source_project: project)
merge_request = create(:merge_request)
expect(merge_request.has_terraform_reports?).to be_falsey
end
@ -1802,8 +1804,7 @@ RSpec.describe MergeRequest do
end
describe '#calculate_reactive_cache' do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request) }
subject { merge_request.calculate_reactive_cache(service_class_name) }
@ -2131,6 +2132,8 @@ RSpec.describe MergeRequest do
end
describe '#can_be_reverted?' do
subject { create(:merge_request, source_project: create(:project, :repository)) }
context 'when there is no merge_commit for the MR' do
before do
subject.metrics.update!(merged_at: Time.current.utc)
@ -2319,8 +2322,6 @@ RSpec.describe MergeRequest do
end
describe '#participants' do
let(:project) { create(:project, :public) }
let(:mr) do
create(:merge_request, source_project: project, target_project: project)
end
@ -2428,9 +2429,7 @@ RSpec.describe MergeRequest do
end
describe '#mergeable?' do
let(:project) { create(:project) }
subject { create(:merge_request, source_project: project) }
subject { build_stubbed(:merge_request) }
it 'returns false if #mergeable_state? is false' do
expect(subject).to receive(:mergeable_state?) { false }
@ -2500,9 +2499,7 @@ RSpec.describe MergeRequest do
end
describe '#mergeable_state?' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) }
subject { create(:merge_request) }
it 'checks if merge request can be merged' do
allow(subject).to receive(:mergeable_ci_state?) { true }
@ -2617,7 +2614,7 @@ RSpec.describe MergeRequest do
let(:pipeline) { create(:ci_empty_pipeline) }
context 'when it is only allowed to merge when build is green' do
let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true) }
let_it_be(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true) }
subject { build(:merge_request, target_project: project) }
@ -2658,7 +2655,7 @@ RSpec.describe MergeRequest do
end
context 'when it is only allowed to merge when build is green or skipped' do
let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true, allow_merge_on_skipped_pipeline: true) }
let_it_be(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true, allow_merge_on_skipped_pipeline: true) }
subject { build(:merge_request, target_project: project) }
@ -2699,7 +2696,7 @@ RSpec.describe MergeRequest do
end
context 'when merges are not restricted to green builds' do
let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: false) }
let_it_be(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: false) }
subject { build(:merge_request, target_project: project) }
@ -2743,7 +2740,7 @@ RSpec.describe MergeRequest do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) }
context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) }
let_it_be(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) }
context 'with all discussions resolved' do
before do
@ -2992,6 +2989,10 @@ RSpec.describe MergeRequest do
end
describe '#branch_merge_base_commit' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) }
context 'source and target branch exist' do
it { expect(subject.branch_merge_base_commit.sha).to eq('ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }
it { expect(subject.branch_merge_base_commit).to be_a(Commit) }
@ -3011,7 +3012,9 @@ RSpec.describe MergeRequest do
describe "#diff_refs" do
context "with diffs" do
subject { create(:merge_request, :with_diffs) }
let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) }
let(:expected_diff_refs) do
Gitlab::Diff::DiffRefs.new(
@ -3213,7 +3216,8 @@ RSpec.describe MergeRequest do
pipeline
end
let(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) }
let_it_be(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) }
let(:developer) { create(:user) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
@ -3307,8 +3311,7 @@ RSpec.describe MergeRequest do
end
describe '#pipeline_coverage_delta' do
let!(:project) { create(:project, :repository) }
let!(:merge_request) { create(:merge_request, source_project: project) }
let!(:merge_request) { create(:merge_request) }
let!(:source_pipeline) do
create(:ci_pipeline,
@ -3414,7 +3417,9 @@ RSpec.describe MergeRequest do
end
describe '#merge_request_diff_for' do
subject { create(:merge_request, importing: true) }
let(:project) { create(:project, :repository) }
subject { create(:merge_request, importing: true, source_project: project) }
let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
@ -3445,9 +3450,10 @@ RSpec.describe MergeRequest do
end
describe '#version_params_for' do
subject { create(:merge_request, importing: true) }
let(:project) { create(:project, :repository) }
subject { create(:merge_request, importing: true, source_project: project) }
let(:project) { subject.project }
let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
@ -3478,6 +3484,10 @@ RSpec.describe MergeRequest do
end
describe '#fetch_ref!' do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, :with_diffs, source_project: project) }
it 'fetches the ref correctly' do
expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error
@ -3500,8 +3510,10 @@ RSpec.describe MergeRequest do
end
context 'state machine transitions' do
let(:project) { create(:project, :repository) }
describe '#unlock_mr' do
subject { create(:merge_request, state: 'locked', merge_jid: 123) }
subject { create(:merge_request, state: 'locked', source_project: project, merge_jid: 123) }
it 'updates merge request head pipeline and sets merge_jid to nil', :sidekiq_might_not_need_inline do
pipeline = create(:ci_empty_pipeline, project: subject.project, ref: subject.source_branch, sha: subject.source_branch_sha)
@ -3518,7 +3530,7 @@ RSpec.describe MergeRequest do
let(:notification_service) { double(:notification_service) }
let(:todo_service) { double(:todo_service) }
subject { create(:merge_request, state, merge_status: :unchecked) }
subject { create(:merge_request, state, source_project: project, merge_status: :unchecked) }
before do
allow(NotificationService).to receive(:new).and_return(notification_service)
@ -3607,7 +3619,7 @@ RSpec.describe MergeRequest do
end
context 'source branch is missing' do
subject { create(:merge_request, :invalid, :opened, merge_status: :unchecked, target_branch: 'master') }
subject { create(:merge_request, :invalid, :opened, source_project: project, merge_status: :unchecked, target_branch: 'master') }
before do
allow(subject.project.repository).to receive(:can_be_merged?).and_call_original
@ -3640,10 +3652,8 @@ RSpec.describe MergeRequest do
end
describe '#should_be_rebased?' do
let(:project) { create(:project, :repository) }
it 'returns false for the same source and target branches' do
merge_request = create(:merge_request, source_project: project, target_project: project)
merge_request = build_stubbed(:merge_request, source_project: project, target_project: project)
expect(merge_request.should_be_rebased?).to be_falsey
end
@ -3658,7 +3668,7 @@ RSpec.describe MergeRequest do
end
with_them do
let(:merge_request) { create(:merge_request) }
let(:merge_request) { build_stubbed(:merge_request) }
subject { merge_request.rebase_in_progress? }
@ -3881,7 +3891,7 @@ RSpec.describe MergeRequest do
describe '#cleanup_refs' do
subject { merge_request.cleanup_refs(only: only) }
let(:merge_request) { build(:merge_request) }
let(:merge_request) { build(:merge_request, source_project: create(:project, :repository)) }
context 'when removing all refs' do
let(:only) { :all }