Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-04 01:23:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-04 01:23:33 +0300
commit6c3124c854cbeef391a38b5ae8330174d78348bf (patch)
treeaf77629bc34ccc517ed24d9db35895be5d02d23d /spec
parent9a8ae3b4e90e56f71bb770463b943512efdcd1d1 (diff)
Add latest changes from gitlab-org/gitlab@15-0-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/issues/show/utils_spec.js116
-rw-r--r--spec/frontend/notes/components/comment_form_spec.js20
-rw-r--r--spec/helpers/issues_helper_spec.rb12
-rw-r--r--spec/lib/backup/gitaly_backup_spec.rb10
-rw-r--r--spec/lib/gitlab/usage/service_ping_report_spec.rb29
-rw-r--r--spec/models/user_spec.rb20
-rw-r--r--spec/requests/api/users_spec.rb20
-rw-r--r--spec/services/users/destroy_service_spec.rb21
8 files changed, 226 insertions, 22 deletions
diff --git a/spec/frontend/issues/show/utils_spec.js b/spec/frontend/issues/show/utils_spec.js
index e5f14cfc01a..603fb5cc2a6 100644
--- a/spec/frontend/issues/show/utils_spec.js
+++ b/spec/frontend/issues/show/utils_spec.js
@@ -2,7 +2,7 @@ import { convertDescriptionWithNewSort } from '~/issues/show/utils';
describe('app/assets/javascripts/issues/show/utils.js', () => {
describe('convertDescriptionWithNewSort', () => {
- it('converts markdown description with new list sort order', () => {
+ it('converts markdown description with nested lists with new list sort order', () => {
const description = `I am text
- Item 1
@@ -12,17 +12,17 @@ describe('app/assets/javascripts/issues/show/utils.js', () => {
- Item 5`;
// Drag Item 2 + children to Item 1's position
- const html = `<ul data-sourcepos="3:1-8:0">
- <li data-sourcepos="4:1-4:8">
+ const html = `<ul data-sourcepos="3:1-7:8">
+ <li data-sourcepos="4:1-6:10">
Item 2
- <ul data-sourcepos="5:1-6:10">
- <li data-sourcepos="5:1-5:10">Item 3</li>
- <li data-sourcepos="6:1-6:10">Item 4</li>
+ <ul data-sourcepos="5:3-6:10">
+ <li data-sourcepos="5:3-5:10">Item 3</li>
+ <li data-sourcepos="6:3-6:10">Item 4</li>
</ul>
</li>
<li data-sourcepos="3:1-3:8">Item 1</li>
- <li data-sourcepos="7:1-8:0">Item 5</li>
- <ul>`;
+ <li data-sourcepos="7:1-7:8">Item 5</li>
+ </ul>`;
const list = document.createElement('div');
list.innerHTML = html;
@@ -36,5 +36,105 @@ describe('app/assets/javascripts/issues/show/utils.js', () => {
expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected);
});
+
+ it('converts markdown description with multi-line list items with new list sort order', () => {
+ const description = `Labore ea omnis et officia excepturi.
+
+1. Item 1
+
+ Item 1 part 2
+
+1. Item 2
+ - Item 2.1
+ - Item 2.1.1
+ - Item 2.1.2
+ - Item 2.2
+ - Item 2.3
+1. Item 3
+1. Item 4
+
+ \`\`\`
+ const variable = 'string';
+ \`\`\`
+
+ ![iii](img.jpg)
+
+ last paragraph
+
+1. Item 5
+1. Item 6`;
+
+ // Drag Item 2 + children to Item 5's position
+ const html = `<ol data-sourcepos="3:1-25:7">
+ <li data-sourcepos="3:1-6:0">
+ <p data-sourcepos="3:4-3:7">Item 1</p>
+ <p data-sourcepos="5:4-5:8">Item 1 part 2</p>
+ </li>
+ <li data-sourcepos="13:1-13:7">
+ <p data-sourcepos="13:4-13:7">Item 3</p>
+ </li>
+ <li data-sourcepos="14:1-23:0">
+ <p data-sourcepos="14:4-14:7">Item 4</p>
+ <div>
+ <pre data-sourcepos="16:4-18:6">
+ <code><span lang="plaintext">const variabl = 'string';</span></code>
+ </pre>
+ </div>
+ <p data-sourcepos="20:4-20:32">
+ <a href="href"><img src="img.jpg" alt="description" /></a>
+ </p>
+ <p data-sourcepos="22:4-22:17">last paragraph</p>
+ </li>
+ <li data-sourcepos="24:1-24:7">
+ <p data-sourcepos="24:4-24:7">Item 5</p>
+ </li>
+ <li data-sourcepos="7:1-12:10">
+ <p data-sourcepos="7:4-7:7">Item 2</p>
+ <ul data-sourcepos="8:4-12:10">
+ <li data-sourcepos="8:4-10:15">Item 2.1
+ <ul data-sourcepos="9:6-10:15">
+ <li data-sourcepos="9:6-9:12">Item 2.1.1</li>
+ <li data-sourcepos="10:6-10:15">Item 2.1.2</li>
+ </ul>
+ </li>
+ <li data-sourcepos="11:4-11:10">Item 2.2</li>
+ <li data-sourcepos="12:4-12:10">Item 2.3</li>
+ </ul>
+ </li>
+ <li data-sourcepos="25:1-25:7">
+ <p data-sourcepos="25:4-25:7">Item 6</p>
+ </li>
+ </ol>`;
+ const list = document.createElement('div');
+ list.innerHTML = html;
+
+ const expected = `Labore ea omnis et officia excepturi.
+
+1. Item 1
+
+ Item 1 part 2
+
+1. Item 3
+1. Item 4
+
+ \`\`\`
+ const variable = 'string';
+ \`\`\`
+
+ ![iii](img.jpg)
+
+ last paragraph
+
+1. Item 5
+1. Item 2
+ - Item 2.1
+ - Item 2.1.1
+ - Item 2.1.2
+ - Item 2.2
+ - Item 2.3
+1. Item 6`;
+
+ expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected);
+ });
});
});
diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js
index fb42e4d1d84..ba5d4d27e55 100644
--- a/spec/frontend/notes/components/comment_form_spec.js
+++ b/spec/frontend/notes/components/comment_form_spec.js
@@ -582,6 +582,26 @@ describe('issue_comment_form component', () => {
expect(checkbox.element.checked).toBe(false);
});
+ it.each`
+ noteableType | rendered | message
+ ${'Issue'} | ${true} | ${'render'}
+ ${'Epic'} | ${true} | ${'render'}
+ ${'MergeRequest'} | ${false} | ${'not render'}
+ `(
+ 'should $message checkbox when noteableType is $noteableType',
+ ({ noteableType, rendered }) => {
+ mountComponent({
+ mountFunction: mount,
+ noteableType,
+ initialData: { note: 'internal note' },
+ noteableData: { ...notableDataMockCanUpdateIssuable, noteableType },
+ features,
+ });
+
+ expect(findConfidentialNoteCheckbox().exists()).toBe(rendered);
+ },
+ );
+
describe.each`
shouldCheckboxBeChecked
${true}
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 0421c7b7458..58f06899cd6 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -302,7 +302,7 @@ RSpec.describe IssuesHelper do
is_anonymous_search_disabled: 'true',
is_issue_repositioning_disabled: 'true',
is_project: 'true',
- is_public_visibility_restricted: 'false',
+ is_public_visibility_restricted: Gitlab::CurrentSettings.restricted_visibility_levels ? 'false' : '',
is_signed_in: current_user.present?.to_s,
jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'),
markdown_help_path: help_page_path('user/markdown'),
@@ -337,6 +337,16 @@ RSpec.describe IssuesHelper do
let(:current_user) { nil }
end
end
+
+ context 'when restricted visibility levels is nil' do
+ before do
+ allow(Gitlab::CurrentSettings).to receive(:restricted_visibility_levels).and_return(nil)
+ end
+
+ it_behaves_like 'issues list data' do
+ let(:current_user) { double.as_null_object }
+ end
+ end
end
describe '#group_issues_list_data' do
diff --git a/spec/lib/backup/gitaly_backup_spec.rb b/spec/lib/backup/gitaly_backup_spec.rb
index 399e4ffa72b..ab198fcbe1f 100644
--- a/spec/lib/backup/gitaly_backup_spec.rb
+++ b/spec/lib/backup/gitaly_backup_spec.rb
@@ -59,6 +59,16 @@ RSpec.describe Backup::GitalyBackup do
expect(File).to exist(File.join(destination, project_snippet.disk_path, backup_id, '001.bundle'))
end
+ it 'erases any existing repository backups' do
+ existing_file = File.join(destination, 'some_existing_file')
+ IO.write(existing_file, "Some existing file.\n")
+
+ subject.start(:create, destination, backup_id: backup_id)
+ subject.finish!
+
+ expect(File).not_to exist(existing_file)
+ end
+
context 'parallel option set' do
let(:max_parallelism) { 3 }
diff --git a/spec/lib/gitlab/usage/service_ping_report_spec.rb b/spec/lib/gitlab/usage/service_ping_report_spec.rb
index e7096988035..e007554df4a 100644
--- a/spec/lib/gitlab/usage/service_ping_report_spec.rb
+++ b/spec/lib/gitlab/usage/service_ping_report_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_caching do
include UsageDataHelpers
- let(:usage_data) { { uuid: "1111", counts: { issue: 0 } } }
+ let(:usage_data) { { uuid: "1111", counts: { issue: 0 } }.deep_stringify_keys }
before do
allow_next_instance_of(Gitlab::Usage::ServicePing::PayloadKeysProcessor) do |instance|
@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c
context 'all_metrics_values' do
it 'generates the service ping when there are no missing values' do
expect(Gitlab::UsageData).to receive(:data).and_return(usage_data)
- expect(described_class.for(output: :all_metrics_values)).to eq({ uuid: "1111", counts: { issue: 0 } })
+ expect(described_class.for(output: :all_metrics_values)).to eq({ uuid: "1111", counts: { issue: 0 } }.deep_stringify_keys)
end
it 'generates the service ping with the missing values' do
@@ -33,7 +33,24 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c
end
expect(Gitlab::UsageData).to receive(:data).and_return(usage_data)
- expect(described_class.for(output: :all_metrics_values)).to eq({ uuid: "1111", counts: { issue: 0, boards: 1 } })
+ expect(described_class.for(output: :all_metrics_values)).to eq({ uuid: "1111", counts: { issue: 0, boards: 1 } }.deep_stringify_keys)
+ end
+
+ context 'with usage data payload with symbol keys and instrumented payload with string keys' do
+ let(:usage_data) { { uuid: "1111", counts: { issue: 0 } } }
+
+ it 'correctly merges string and symbol keys' do
+ expect_next_instance_of(Gitlab::Usage::ServicePing::PayloadKeysProcessor, usage_data) do |instance|
+ expect(instance).to receive(:missing_instrumented_metrics_key_paths).and_return(['counts.boards'])
+ end
+
+ expect_next_instance_of(Gitlab::Usage::ServicePing::InstrumentedPayload, ['counts.boards'], :with_value) do |instance|
+ expect(instance).to receive(:build).and_return({ 'counts' => { 'boards' => 1 } })
+ end
+
+ expect(Gitlab::UsageData).to receive(:data).and_return(usage_data)
+ expect(described_class.for(output: :all_metrics_values)).to eq({ uuid: "1111", counts: { issue: 0, boards: 1 } }.deep_stringify_keys)
+ end
end
end
@@ -54,9 +71,9 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c
end
context 'when using cached' do
- context 'for cached: true' do
- let(:new_usage_data) { { uuid: "1112" } }
+ let(:new_usage_data) { { 'uuid' => '1112' } }
+ context 'for cached: true' do
it 'caches the values' do
allow(Gitlab::UsageData).to receive(:data).and_return(usage_data, new_usage_data)
@@ -78,8 +95,6 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c
end
context 'when no caching' do
- let(:new_usage_data) { { uuid: "1112" } }
-
it 'returns fresh data' do
allow(Gitlab::UsageData).to receive(:data).and_return(usage_data, new_usage_data)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 71171f98492..f087fab1ef3 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -3740,7 +3740,7 @@ RSpec.describe User do
end
context 'has owned groups' do
- let_it_be(:group) { create(:group) }
+ let(:group) { create(:group) }
before do
group.add_owner(user)
@@ -3749,11 +3749,23 @@ RSpec.describe User do
context 'not solo owner' do
let_it_be(:user2) { create(:user) }
- before do
- group.add_owner(user2)
+ context 'with another direct owner' do
+ before do
+ group.add_owner(user2)
+ end
+
+ it { is_expected.to be_empty }
end
- it { is_expected.to be_empty }
+ context 'with an inherited owner' do
+ let_it_be(:group) { create(:group, :nested) }
+
+ before do
+ group.parent.add_owner(user2)
+ end
+
+ it { is_expected.to be_empty }
+ end
end
context 'solo owner' do
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 040ac4f74a7..2c5a734a0e1 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -2098,7 +2098,7 @@ RSpec.describe API::Users do
describe "DELETE /users/:id" do
let_it_be(:issue) { create(:issue, author: user) }
- it "deletes user", :sidekiq_might_not_need_inline do
+ it "deletes user", :sidekiq_inline do
namespace_id = user.namespace.id
perform_enqueued_jobs { delete api("/users/#{user.id}", admin) }
@@ -2119,11 +2119,27 @@ RSpec.describe API::Users do
end
context "hard delete enabled" do
- it "delete user and group", :sidekiq_might_not_need_inline do
+ it "delete user and group", :sidekiq_inline do
perform_enqueued_jobs { delete api("/users/#{user.id}?hard_delete=true", admin) }
expect(response).to have_gitlab_http_status(:no_content)
expect(Group.exists?(group.id)).to be_falsy
end
+
+ context "with subgroup owning" do
+ let(:parent_group) { create(:group) }
+ let(:subgroup) { create(:group, parent: parent_group) }
+
+ before do
+ parent_group.add_owner(create(:user))
+ subgroup.add_owner(user)
+ end
+
+ it "delete only user", :sidekiq_inline do
+ perform_enqueued_jobs { delete api("/users/#{user.id}?hard_delete=true", admin) }
+ expect(response).to have_gitlab_http_status(:no_content)
+ expect(Group.exists?(subgroup.id)).to be_truthy
+ end
+ end
end
end
diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb
index 45dbe83b496..90c4f70d749 100644
--- a/spec/services/users/destroy_service_spec.rb
+++ b/spec/services/users/destroy_service_spec.rb
@@ -215,6 +215,27 @@ RSpec.describe Users::DestroyService do
end
end
+ context 'deletions with inherited group owners' do
+ let(:group) { create(:group, :nested) }
+ let(:user) { create(:user) }
+ let(:inherited_owner) { create(:user) }
+
+ before do
+ group.parent.add_owner(inherited_owner)
+ group.add_owner(user)
+
+ service.execute(user, delete_solo_owned_groups: true)
+ end
+
+ it 'does not delete the group' do
+ expect(Group.exists?(id: group)).to be_truthy
+ end
+
+ it 'deletes the user' do
+ expect(User.exists?(id: user)).to be_falsey
+ end
+ end
+
context 'migrating associated records' do
let!(:issue) { create(:issue, author: user) }