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>2024-01-16 21:09:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 21:09:25 +0300
commite18006fc6313b1d04128416cdb5f1533adcdb53e (patch)
treead418c4afbfcc8f83bcf5b4a9c897a2139e79e13 /spec
parentcb8835f38a3e4c188e9a73adf45936e2a95f40ae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/authentication/password/components/password_input_spec.js1
-rw-r--r--spec/frontend/members/components/table/members_table_spec.js13
-rw-r--r--spec/frontend/members/index_spec.js4
-rw-r--r--spec/frontend/work_items/components/work_item_assignees_spec.js6
-rw-r--r--spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js4
-rw-r--r--spec/helpers/groups_helper_spec.rb12
-rw-r--r--spec/helpers/work_items_helper_spec.rb6
-rw-r--r--spec/lib/gitlab/auth_spec.rb76
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importers/pull_request_importer_spec.rb5
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importers/pull_request_notes_importer_spec.rb4
-rw-r--r--spec/lib/gitlab/checks/lfs_check_spec.rb12
-rw-r--r--spec/lib/gitlab/import/mentions_converter_spec.rb (renamed from spec/lib/gitlab/bitbucket_server_import/mentions_converter_spec.rb)5
-rw-r--r--spec/lib/gitlab/import/user_from_mention_spec.rb (renamed from spec/lib/gitlab/bitbucket_server_import/user_from_mention_spec.rb)14
-rw-r--r--spec/lib/gitlab/observability_spec.rb47
-rw-r--r--spec/lib/gitlab/protocol_access_spec.rb47
-rw-r--r--spec/lib/google_cloud_platform/artifact_registry/client_spec.rb (renamed from spec/lib/integrations/google_cloud_platform/artifact_registry/client_spec.rb)2
-rw-r--r--spec/lib/google_cloud_platform/jwt_spec.rb (renamed from spec/lib/integrations/google_cloud_platform/jwt_spec.rb)2
-rw-r--r--spec/models/namespace_setting_spec.rb2
-rw-r--r--spec/requests/api/graphql/mutations/notes/create/discussion_spec.rb45
-rw-r--r--spec/requests/api/graphql/mutations/work_items/create_spec.rb12
-rw-r--r--spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb4
-rw-r--r--spec/services/import/github_service_spec.rb34
-rw-r--r--spec/workers/every_sidekiq_worker_spec.rb44
23 files changed, 216 insertions, 185 deletions
diff --git a/spec/frontend/authentication/password/components/password_input_spec.js b/spec/frontend/authentication/password/components/password_input_spec.js
index 62438e824cf..d31bfea224a 100644
--- a/spec/frontend/authentication/password/components/password_input_spec.js
+++ b/spec/frontend/authentication/password/components/password_input_spec.js
@@ -32,7 +32,6 @@ describe('PasswordInput', () => {
expect(findPasswordInput().attributes('autocomplete')).toBe(propsData.autocomplete);
expect(findPasswordInput().attributes('name')).toBe(propsData.name);
expect(findPasswordInput().attributes('minlength')).toBe(propsData.minimumPasswordLength);
- expect(findPasswordInput().attributes('data-qa-selector')).toBe(propsData.qaSelector);
expect(findPasswordInput().attributes('data-testid')).toBe(propsData.testid);
expect(findPasswordInput().attributes('title')).toBe(propsData.title);
});
diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js
index c2400fbc142..9fcf1853ef5 100644
--- a/spec/frontend/members/components/table/members_table_spec.js
+++ b/spec/frontend/members/components/table/members_table_spec.js
@@ -45,8 +45,7 @@ describe('MembersTable', () => {
members: [],
tableFields: [],
tableAttrs: {
- table: { 'data-qa-selector': 'members_list' },
- tr: { 'data-qa-selector': 'member_row' },
+ tr: { 'data-testid': 'member-row' },
},
pagination,
...state,
@@ -274,16 +273,10 @@ describe('MembersTable', () => {
});
});
- it('adds QA selector to table', () => {
+ it('adds QA testid to table row', () => {
createComponent();
- expect(findTable().attributes('data-qa-selector')).toBe('members_list');
- });
-
- it('adds QA selector to table row', () => {
- createComponent();
-
- expect(findTable().find('tbody tr').attributes('data-qa-selector')).toBe('member_row');
+ expect(findTable().find('tbody tr').attributes('data-testid')).toBe('member-row');
});
describe('when required pagination data is provided', () => {
diff --git a/spec/frontend/members/index_spec.js b/spec/frontend/members/index_spec.js
index b1730cf3746..a48ed944292 100644
--- a/spec/frontend/members/index_spec.js
+++ b/spec/frontend/members/index_spec.js
@@ -13,7 +13,7 @@ describe('initMembersApp', () => {
vm = initMembersApp(el, {
[MEMBER_TYPES.user]: {
tableFields: ['account'],
- tableAttrs: { table: { 'data-qa-selector': 'members_list' } },
+ tableAttrs: { table: { 'data-testid': 'members-list' } },
tableSortableFields: ['account'],
requestFormatter: () => ({}),
filteredSearchBar: { show: false },
@@ -61,7 +61,7 @@ describe('initMembersApp', () => {
setup();
expect(vm.$store.state[MEMBER_TYPES.user].tableAttrs).toEqual({
- table: { 'data-qa-selector': 'members_list' },
+ table: { 'data-testid': 'members-list' },
});
});
diff --git a/spec/frontend/work_items/components/work_item_assignees_spec.js b/spec/frontend/work_items/components/work_item_assignees_spec.js
index 6c0042bdad7..b34eed21c60 100644
--- a/spec/frontend/work_items/components/work_item_assignees_spec.js
+++ b/spec/frontend/work_items/components/work_item_assignees_spec.js
@@ -14,9 +14,9 @@ import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutati
import WorkItemAssignees from '~/work_items/components/work_item_assignees.vue';
import {
i18n,
- TASK_TYPE_NAME,
- TRACKING_CATEGORY_SHOW,
DEFAULT_PAGE_SIZE_ASSIGNEES,
+ TRACKING_CATEGORY_SHOW,
+ WORK_ITEM_TYPE_VALUE_TASK,
} from '~/work_items/constants';
import {
projectMembersResponseWithCurrentUser,
@@ -97,7 +97,7 @@ describe('WorkItemAssignees component', () => {
fullPath: 'test-project-path',
workItemId,
allowsMultipleAssignees,
- workItemType: TASK_TYPE_NAME,
+ workItemType: WORK_ITEM_TYPE_VALUE_TASK,
canUpdate,
canInviteMembers,
},
diff --git a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js
index 36af0c5b3c8..3c65a29e438 100644
--- a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js
+++ b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js
@@ -13,8 +13,8 @@ import WorkItemTreeChildren from '~/work_items/components/work_item_links/work_i
import WorkItemLinkChildContents from '~/work_items/components/shared/work_item_link_child_contents.vue';
import {
WIDGET_TYPE_HIERARCHY,
- TASK_TYPE_NAME,
WORK_ITEM_TYPE_VALUE_OBJECTIVE,
+ WORK_ITEM_TYPE_VALUE_TASK,
} from '~/work_items/constants';
import {
@@ -47,7 +47,7 @@ describe('WorkItemLinkChild', () => {
canUpdate = true,
issuableGid = WORK_ITEM_ID,
childItem = workItemTask,
- workItemType = TASK_TYPE_NAME,
+ workItemType = WORK_ITEM_TYPE_VALUE_TASK,
apolloProvider = null,
} = {}) => {
getWorkItemTreeQueryHandler = jest.fn().mockResolvedValue(workItemHierarchyTreeResponse);
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 807898884a1..6c4595ce4bb 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -533,24 +533,22 @@ RSpec.describe GroupsHelper, feature_category: :groups_and_projects do
end
describe "#enabled_git_access_protocol_options_for_group" do
- let_it_be(:group) { create(:group) }
-
- subject { helper.enabled_git_access_protocol_options_for_group(group) }
+ subject { helper.enabled_git_access_protocol_options_for_group }
before do
- allow(::Gitlab::CurrentSettings).to receive(:enabled_git_access_protocol).and_return(instance_setting)
+ expect(::Gitlab::CurrentSettings).to receive(:enabled_git_access_protocol).and_return(instance_setting)
end
context "instance setting is nil" do
let(:instance_setting) { nil }
- it { is_expected.to include([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
+ it { is_expected.to contain_exactly([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
end
context "instance setting is blank" do
- let(:instance_setting) { '' }
+ let(:instance_setting) { nil }
- it { is_expected.to include([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
+ it { is_expected.to contain_exactly([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
end
context "instance setting is ssh" do
diff --git a/spec/helpers/work_items_helper_spec.rb b/spec/helpers/work_items_helper_spec.rb
index b790f21d412..59b8b13aea2 100644
--- a/spec/helpers/work_items_helper_spec.rb
+++ b/spec/helpers/work_items_helper_spec.rb
@@ -3,13 +3,13 @@
require "spec_helper"
RSpec.describe WorkItemsHelper, feature_category: :team_planning do
- describe '#work_items_index_data' do
- subject(:work_items_index_data) { helper.work_items_index_data(project) }
+ describe '#work_items_show_data' do
+ subject(:work_items_show_data) { helper.work_items_show_data(project) }
let_it_be(:project) { build(:project) }
it 'returns the expected data properties' do
- expect(work_items_index_data).to include(
+ expect(work_items_show_data).to include(
{
full_path: project.full_path,
issues_list_path: project_issues_path(project),
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index fd51ebbc8fa..3c87ac258b3 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -75,10 +75,12 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching, feature_cate
expect(subject.optional_scopes).to match_array %i[read_user read_api read_repository write_repository read_registry read_service_ping write_registry sudo admin_mode openid profile email read_observability write_observability create_runner k8s_proxy ai_features]
end
- context 'with observability_tracing feature flag' do
- context 'when disabled' do
+ context 'with observability feature flags' do
+ feature_flags = [:observability_tracing, :observability_metrics]
+
+ context 'when all disabled' do
before do
- stub_feature_flags(observability_tracing: false)
+ stub_feature_flags(feature_flags.index_with { false })
end
it 'contains for group all resource bot scopes without observability scopes' do
@@ -99,49 +101,55 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching, feature_cate
end
end
- context 'when enabled for specific root group' do
- let(:parent) { build_stubbed(:group) }
- let(:group) do
- build_stubbed(:group, parent: parent).tap { |g| g.namespace_settings = build_stubbed(:namespace_settings, namespace: g) }
- end
+ flag_states = [true, false].repeated_permutation(feature_flags.length)
+ flag_tests = flag_states.filter(&:any?).map { |flags| Hash[feature_flags.zip(flags)] }
- let(:project) { build_stubbed(:project, namespace: group) }
+ flag_tests.each do |flags|
+ context "with flags #{flags} enabled for specific root group" do
+ let(:parent) { build_stubbed(:group) }
+ let(:group) do
+ build_stubbed(:group, parent: parent).tap { |g| g.namespace_settings = build_stubbed(:namespace_settings, namespace: g) }
+ end
- before do
- stub_feature_flags(observability_tracing: parent)
- end
+ let(:project) { build_stubbed(:project, namespace: group) }
- it 'contains for group all resource bot scopes including observability scopes' do
- expect(subject.available_scopes_for(group)).to match_array %i[api read_api read_repository write_repository read_registry write_registry read_observability write_observability create_runner k8s_proxy ai_features]
- end
+ before do
+ flags.transform_values! { |v| v ? parent : false }
+ stub_feature_flags(flags)
+ end
- it 'contains for admin user all non-default scopes with ADMIN access and without observability scopes' do
- user = build_stubbed(:user, admin: true)
+ it 'contains for group all resource bot scopes including observability scopes' do
+ expect(subject.available_scopes_for(group)).to match_array %i[api read_api read_repository write_repository read_registry write_registry read_observability write_observability create_runner k8s_proxy ai_features]
+ end
- expect(subject.available_scopes_for(user)).to match_array %i[api read_user read_api read_repository write_repository read_registry write_registry read_service_ping sudo admin_mode create_runner k8s_proxy ai_features]
- end
+ it 'contains for admin user all non-default scopes with ADMIN access and without observability scopes' do
+ user = build_stubbed(:user, admin: true)
- it 'contains for project all resource bot scopes including observability scopes' do
- expect(subject.available_scopes_for(project)).to match_array %i[api read_api read_repository write_repository read_registry write_registry read_observability write_observability create_runner k8s_proxy ai_features]
- end
+ expect(subject.available_scopes_for(user)).to match_array %i[api read_user read_api read_repository write_repository read_registry write_registry read_service_ping sudo admin_mode create_runner k8s_proxy ai_features]
+ end
- it 'contains for other group all resource bot scopes without observability scopes' do
- other_parent = build_stubbed(:group)
- other_group = build_stubbed(:group, parent: other_parent).tap do |g|
- g.namespace_settings = build_stubbed(:namespace_settings, namespace: g)
+ it 'contains for project all resource bot scopes including observability scopes' do
+ expect(subject.available_scopes_for(project)).to match_array %i[api read_api read_repository write_repository read_registry write_registry read_observability write_observability create_runner k8s_proxy ai_features]
end
- expect(subject.available_scopes_for(other_group)).to match_array %i[api read_api read_repository write_repository read_registry write_registry create_runner k8s_proxy ai_features]
- end
+ it 'contains for other group all resource bot scopes without observability scopes' do
+ other_parent = build_stubbed(:group)
+ other_group = build_stubbed(:group, parent: other_parent).tap do |g|
+ g.namespace_settings = build_stubbed(:namespace_settings, namespace: g)
+ end
- it 'contains for other project all resource bot scopes without observability scopes' do
- other_parent = build_stubbed(:group)
- other_group = build_stubbed(:group, parent: other_parent).tap do |g|
- g.namespace_settings = build_stubbed(:namespace_settings, namespace: g)
+ expect(subject.available_scopes_for(other_group)).to match_array %i[api read_api read_repository write_repository read_registry write_registry create_runner k8s_proxy ai_features]
end
- other_project = build_stubbed(:project, namespace: other_group)
- expect(subject.available_scopes_for(other_project)).to match_array %i[api read_api read_repository write_repository read_registry write_registry create_runner k8s_proxy ai_features]
+ it 'contains for other project all resource bot scopes without observability scopes' do
+ other_parent = build_stubbed(:group)
+ other_group = build_stubbed(:group, parent: other_parent).tap do |g|
+ g.namespace_settings = build_stubbed(:namespace_settings, namespace: g)
+ end
+ other_project = build_stubbed(:project, namespace: other_group)
+
+ expect(subject.available_scopes_for(other_project)).to match_array %i[api read_api read_repository write_repository read_registry write_registry create_runner k8s_proxy ai_features]
+ end
end
end
end
diff --git a/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_importer_spec.rb
index eeb2f9c8000..bff25fb723f 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_importer_spec.rb
@@ -18,7 +18,8 @@ RSpec.describe Gitlab::BitbucketServerImport::Importers::PullRequestImporter, fe
it 'imports the merge request correctly' do
expect_next(Gitlab::Import::MergeRequestCreator, project).to receive(:execute).and_call_original
expect_next(Gitlab::BitbucketServerImport::UserFinder, project).to receive(:author_id).and_call_original
- expect_next(Gitlab::BitbucketServerImport::MentionsConverter, project.id).to receive(:convert).and_call_original
+ expect_next(Gitlab::Import::MentionsConverter, 'bitbucket_server',
+ project.id).to receive(:convert).and_call_original
expect { importer.execute }.to change { MergeRequest.count }.by(1)
@@ -42,7 +43,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importers::PullRequestImporter, fe
end
it 'does not convert mentions' do
- expect_next(Gitlab::BitbucketServerImport::MentionsConverter, project.id).not_to receive(:convert)
+ expect_next(Gitlab::Import::MentionsConverter, 'bitbucket_server', project.id).not_to receive(:convert)
importer.execute
end
diff --git a/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_notes_importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_notes_importer_spec.rb
index 7b662c1a2c7..31035d8844e 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_notes_importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importers/pull_request_notes_importer_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importers::PullRequestNotesImporte
let_it_be(:pull_request_data) { Gitlab::Json.parse(fixture_file('importers/bitbucket_server/pull_request.json')) }
let_it_be(:pull_request) { BitbucketServer::Representation::PullRequest.new(pull_request_data) }
let_it_be(:note_author) { create(:user, username: 'note_author', email: 'note_author@example.org') }
- let(:mentions_converter) { Gitlab::BitbucketServerImport::MentionsConverter.new(project) }
+ let(:mentions_converter) { Gitlab::Import::MentionsConverter.new('bitbucket_server', project) }
let!(:pull_request_author) do
create(:user, username: 'pull_request_author', email: 'pull_request_author@example.org')
@@ -81,7 +81,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importers::PullRequestNotesImporte
end
before do
- allow(Gitlab::BitbucketServerImport::MentionsConverter).to receive(:new).and_return(mentions_converter)
+ allow(Gitlab::Import::MentionsConverter).to receive(:new).and_return(mentions_converter)
end
subject(:importer) { described_class.new(project.reload, pull_request.to_hash) }
diff --git a/spec/lib/gitlab/checks/lfs_check_spec.rb b/spec/lib/gitlab/checks/lfs_check_spec.rb
index f00915bc1ec..ef27b30475f 100644
--- a/spec/lib/gitlab/checks/lfs_check_spec.rb
+++ b/spec/lib/gitlab/checks/lfs_check_spec.rb
@@ -31,18 +31,6 @@ RSpec.describe Gitlab::Checks::LfsCheck, feature_category: :source_code_manageme
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- context 'with lfs_check feature disabled' do
- before do
- stub_feature_flags(lfs_check: false)
- end
-
- it 'skips integrity check' do
- expect_any_instance_of(Gitlab::Git::LfsChanges).not_to receive(:new_pointers)
-
- subject.validate!
- end
- end
-
context 'with deletion' do
shared_examples 'a skipped integrity check' do
it 'skips integrity check' do
diff --git a/spec/lib/gitlab/bitbucket_server_import/mentions_converter_spec.rb b/spec/lib/gitlab/import/mentions_converter_spec.rb
index 46800c924c9..122d7f227cc 100644
--- a/spec/lib/gitlab/bitbucket_server_import/mentions_converter_spec.rb
+++ b/spec/lib/gitlab/import/mentions_converter_spec.rb
@@ -2,12 +2,13 @@
require 'spec_helper'
-RSpec.describe Gitlab::BitbucketServerImport::MentionsConverter, :clean_gitlab_redis_cache, feature_category: :importers do
+RSpec.describe Gitlab::Import::MentionsConverter, :clean_gitlab_redis_cache, feature_category: :importers do
let(:project_id) { 12 }
+ let(:importer) { 'bitbucket_server' }
let(:text) { 'text without @ mentions' }
let(:source_user_cache_prefix) { "bitbucket_server/project/#{project_id}/source/username" }
- subject(:converted_text) { described_class.new(project_id).convert(text) }
+ subject(:converted_text) { described_class.new(importer, project_id).convert(text) }
describe '#convert' do
context 'when the text has no mentions' do
diff --git a/spec/lib/gitlab/bitbucket_server_import/user_from_mention_spec.rb b/spec/lib/gitlab/import/user_from_mention_spec.rb
index 73f9cde8322..0dcd7f92ee6 100644
--- a/spec/lib/gitlab/bitbucket_server_import/user_from_mention_spec.rb
+++ b/spec/lib/gitlab/import/user_from_mention_spec.rb
@@ -2,22 +2,24 @@
require 'spec_helper'
-RSpec.describe Gitlab::BitbucketServerImport::UserFromMention, :clean_gitlab_redis_cache, feature_category: :importers do
+RSpec.describe Gitlab::Import::UserFromMention, :clean_gitlab_redis_cache, feature_category: :importers do
let(:project_id) { 11 }
let(:username) { '@johndoe' }
let(:email) { 'john@gmail.com' }
let(:hash) { { key: 'value' } }
- let(:cache_key) { "bitbucket_server/project/#{project_id}/source/username/#{username}" }
+ let(:importer) { 'bitbucket_server' }
+ let(:cache_key) { "#{importer}/project/#{project_id}/source/username/#{username}" }
let(:example) do
Class.new do
- include Gitlab::BitbucketServerImport::UserFromMention
+ include Gitlab::Import::UserFromMention
- def initialize(project_id)
+ def initialize(importer, project_id)
+ @importer = importer
@project_id = project_id
end
- attr_reader :project_id
+ attr_reader :project_id, :importer
def foo(mention)
user_from_cache(mention)
@@ -29,7 +31,7 @@ RSpec.describe Gitlab::BitbucketServerImport::UserFromMention, :clean_gitlab_red
end
end
- subject(:example_class) { example.new(project_id) }
+ subject(:example_class) { example.new(importer, project_id) }
describe '#user_from_cache' do
it 'returns nil if the cache is empty' do
diff --git a/spec/lib/gitlab/observability_spec.rb b/spec/lib/gitlab/observability_spec.rb
index 7af2daea11c..221923ac12a 100644
--- a/spec/lib/gitlab/observability_spec.rb
+++ b/spec/lib/gitlab/observability_spec.rb
@@ -56,44 +56,35 @@ RSpec.describe Gitlab::Observability, feature_category: :error_tracking do
end
end
- before do
- stub_feature_flags(observability_tracing: parent)
- end
-
- describe 'when resource is group' do
- context 'if observability_tracing FF enabled' do
- it { is_expected.to be true }
- end
+ feature_flags = [:observability_tracing, :observability_metrics]
+ flag_states = [true, false].repeated_permutation(feature_flags.length)
+ flag_tests = flag_states.map { |flags| Hash[feature_flags.zip(flags)] }
- context 'if observability_tracing FF disabled' do
+ flag_tests.each do |flags|
+ context "with feature flag state #{flags}" do
before do
- stub_feature_flags(observability_tracing: false)
+ flags.transform_values! { |v| v ? parent : false }
+ stub_feature_flags(flags)
end
- it { is_expected.to be false }
- end
- end
+ let(:expected_enabled) { flags.values.any? }
- describe 'when resource is project' do
- let(:resource) { build_stubbed(:project, namespace: parent) }
+ describe 'when resource is group' do
+ it { is_expected.to be expected_enabled }
+ end
- context 'if observability_tracing FF enabled' do
- it { is_expected.to be true }
- end
+ describe 'when resource is project' do
+ let(:resource) { build_stubbed(:project, namespace: parent) }
- context 'if observability_tracing FF disabled' do
- before do
- stub_feature_flags(observability_tracing: false)
+ it { is_expected.to be expected_enabled }
end
- it { is_expected.to be false }
- end
- end
+ describe 'when resource is not a group or project' do
+ let(:resource) { build_stubbed(:user) }
- describe 'when resource is not a group or project' do
- let(:resource) { build_stubbed(:user) }
-
- it { is_expected.to be false }
+ it { is_expected.to be false }
+ end
+ end
end
end
end
diff --git a/spec/lib/gitlab/protocol_access_spec.rb b/spec/lib/gitlab/protocol_access_spec.rb
index cae14c3d7cf..e7e81b4b3e1 100644
--- a/spec/lib/gitlab/protocol_access_spec.rb
+++ b/spec/lib/gitlab/protocol_access_spec.rb
@@ -10,34 +10,25 @@ RSpec.describe Gitlab::ProtocolAccess, feature_category: :source_code_management
describe ".allowed?" do
where(:protocol, :project, :admin_setting, :namespace_setting, :expected_result) do
- "web" | nil | nil | nil | true
- "ssh" | nil | nil | nil | true
- "http" | nil | nil | nil | true
- "ssh_certificates" | nil | nil | nil | true
- "ssh" | nil | "" | nil | true
- "http" | nil | "" | nil | true
- "ssh_certificates" | nil | "" | nil | true
- "ssh" | nil | "ssh" | nil | true
- "http" | nil | "http" | nil | true
- "ssh_certificates" | nil | "ssh_certificates" | nil | true
- "ssh" | nil | "http" | nil | false
- "http" | nil | "ssh" | nil | false
- "ssh_certificates" | nil | "ssh" | nil | false
- "ssh" | ref(:p1) | nil | "all" | true
- "http" | ref(:p1) | nil | "all" | true
- "ssh_certificates" | ref(:p1) | nil | "all" | true
- "ssh" | ref(:p1) | nil | "ssh" | true
- "http" | ref(:p1) | nil | "http" | true
- "ssh_certificates" | ref(:p1) | nil | "ssh_certificates" | true
- "ssh" | ref(:p1) | nil | "http" | false
- "http" | ref(:p1) | nil | "ssh" | false
- "ssh_certificates" | ref(:p1) | nil | "ssh" | false
- "ssh" | ref(:p1) | "" | "all" | true
- "http" | ref(:p1) | "" | "all" | true
- "ssh_certificates" | ref(:p1) | "" | "all" | true
- "ssh" | ref(:p1) | "ssh" | "ssh" | true
- "http" | ref(:p1) | "http" | "http" | true
- "ssh_certificates" | ref(:p1) | "ssh_certificates" | "ssh_certificates" | true
+ "web" | nil | nil | nil | true
+ "ssh" | nil | nil | nil | true
+ "http" | nil | nil | nil | true
+ "ssh" | nil | "" | nil | true
+ "http" | nil | "" | nil | true
+ "ssh" | nil | "ssh" | nil | true
+ "http" | nil | "http" | nil | true
+ "ssh" | nil | "http" | nil | false
+ "http" | nil | "ssh" | nil | false
+ "ssh" | ref(:p1) | nil | "all" | true
+ "http" | ref(:p1) | nil | "all" | true
+ "ssh" | ref(:p1) | nil | "ssh" | true
+ "http" | ref(:p1) | nil | "http" | true
+ "ssh" | ref(:p1) | nil | "http" | false
+ "http" | ref(:p1) | nil | "ssh" | false
+ "ssh" | ref(:p1) | "" | "all" | true
+ "http" | ref(:p1) | "" | "all" | true
+ "ssh" | ref(:p1) | "ssh" | "ssh" | true
+ "http" | ref(:p1) | "http" | "http" | true
end
with_them do
diff --git a/spec/lib/integrations/google_cloud_platform/artifact_registry/client_spec.rb b/spec/lib/google_cloud_platform/artifact_registry/client_spec.rb
index a258518953a..09ddba7c091 100644
--- a/spec/lib/integrations/google_cloud_platform/artifact_registry/client_spec.rb
+++ b/spec/lib/google_cloud_platform/artifact_registry/client_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::GoogleCloudPlatform::ArtifactRegistry::Client, feature_category: :container_registry do
+RSpec.describe GoogleCloudPlatform::ArtifactRegistry::Client, feature_category: :container_registry do
let_it_be(:project) { create(:project) }
let_it_be(:rsa_key) { OpenSSL::PKey::RSA.generate(3072) }
let_it_be(:rsa_key_data) { rsa_key.to_s }
diff --git a/spec/lib/integrations/google_cloud_platform/jwt_spec.rb b/spec/lib/google_cloud_platform/jwt_spec.rb
index 51707c26a3a..d41056a8606 100644
--- a/spec/lib/integrations/google_cloud_platform/jwt_spec.rb
+++ b/spec/lib/google_cloud_platform/jwt_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Integrations::GoogleCloudPlatform::Jwt, feature_category: :shared do
+RSpec.describe GoogleCloudPlatform::Jwt, feature_category: :shared do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
diff --git a/spec/models/namespace_setting_spec.rb b/spec/models/namespace_setting_spec.rb
index c7449e047b0..07ac3248c0a 100644
--- a/spec/models/namespace_setting_spec.rb
+++ b/spec/models/namespace_setting_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe NamespaceSetting, feature_category: :groups_and_projects, type: :
end
it { is_expected.to define_enum_for(:jobs_to_be_done).with_values([:basics, :move_repository, :code_storage, :exploring, :ci, :other]).with_suffix }
- it { is_expected.to define_enum_for(:enabled_git_access_protocol).with_suffix }
+ it { is_expected.to define_enum_for(:enabled_git_access_protocol).with_values([:all, :ssh, :http]).with_suffix }
describe 'default values' do
subject(:setting) { described_class.new }
diff --git a/spec/requests/api/graphql/mutations/notes/create/discussion_spec.rb b/spec/requests/api/graphql/mutations/notes/create/discussion_spec.rb
new file mode 100644
index 00000000000..c7ed63c2560
--- /dev/null
+++ b/spec/requests/api/graphql/mutations/notes/create/discussion_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Adding an DiscussionNote', feature_category: :code_review_workflow do
+ include GraphqlHelpers
+
+ let_it_be(:current_user) { create(:user) }
+
+ let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
+ let(:project) { create(:project, :repository) }
+ let(:diff_refs) { noteable.diff_refs }
+ let(:mutation) do
+ variables = {
+ noteable_id: GitlabSchema.id_from_object(noteable).to_s,
+ body: 'Body text'
+ }
+
+ graphql_mutation(:create_discussion, variables)
+ end
+
+ def mutation_response
+ graphql_mutation_response(:create_discussion)
+ end
+
+ it_behaves_like 'a Note mutation when the user does not have permission'
+
+ context 'when the user has permission' do
+ before do
+ project.add_developer(current_user)
+ end
+
+ it_behaves_like 'a Note mutation that creates a Note'
+
+ it_behaves_like 'a Note mutation when there are active record validation errors', model: DiscussionNote
+
+ it_behaves_like 'a Note mutation when there are rate limit validation errors'
+
+ it 'returns the discussion' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(mutation_response['note']['body']).to eq('Body text')
+ end
+ end
+end
diff --git a/spec/requests/api/graphql/mutations/work_items/create_spec.rb b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
index 2c2cd5f2acc..78b93c3210b 100644
--- a/spec/requests/api/graphql/mutations/work_items/create_spec.rb
+++ b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
@@ -281,18 +281,6 @@ RSpec.describe 'Create a work item', feature_category: :team_planning do
it_behaves_like 'creates work item'
- # This is a temporary measure just to ensure the internal id migration doesn't get conflicts
- # More info in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139367
- context 'when making the request in a production environment' do
- before do
- stub_rails_env('production')
- end
-
- it_behaves_like 'a mutation that returns top-level errors', errors: [
- 'Group level work items are disabled. Only project paths allowed in `namespacePath`.'
- ]
- end
-
context 'when the namespace_level_work_items feature flag is disabled' do
before do
stub_feature_flags(namespace_level_work_items: false)
diff --git a/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb b/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb
index f19cbaa21cd..d772634e682 100644
--- a/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb
+++ b/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb
@@ -26,10 +26,10 @@ RSpec.describe GoogleCloudPlatform::ArtifactRegistry::ListDockerImagesService, f
describe '#execute' do
let(:page_token) { nil }
let(:list_docker_images_response) { dummy_list_response }
- let(:client_double) { instance_double('::Integrations::GoogleCloudPlatform::ArtifactRegistry::Client') }
+ let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') }
before do
- allow(::Integrations::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new)
+ allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new)
.with(
project: project,
user: user,
diff --git a/spec/services/import/github_service_spec.rb b/spec/services/import/github_service_spec.rb
index 6fe17a31f3e..949031b961a 100644
--- a/spec/services/import/github_service_spec.rb
+++ b/spec/services/import/github_service_spec.rb
@@ -202,7 +202,25 @@ RSpec.describe Import::GithubService, feature_category: :importers do
end
end
- context 'validates scopes when collaborator import is true' do
+ context 'validates minimum scope when collaborator import is false' do
+ let(:optional_stages) do
+ {
+ collaborators_import: false
+ }
+ end
+
+ let(:headers) do
+ {
+ 'x-oauth-scopes' => 'write:packages'
+ }
+ end
+
+ it 'returns error when scope is not adequate' do
+ expect(subject.execute(access_params, :github)).to include(minimum_scope_error)
+ end
+ end
+
+ context 'validates collaborator scopes when collaborator import is true' do
let(:optional_stages) do
{
collaborators_import: true
@@ -211,12 +229,12 @@ RSpec.describe Import::GithubService, feature_category: :importers do
let(:headers) do
{
- 'x-oauth-scopes' => 'read:user'
+ 'x-oauth-scopes' => 'repo, read:user'
}
end
it 'returns error when scope is not adequate' do
- expect(subject.execute(access_params, :github)).to include(scope_error)
+ expect(subject.execute(access_params, :github)).to include(collab_import_scope_error)
end
end
@@ -355,7 +373,15 @@ RSpec.describe Import::GithubService, feature_category: :importers do
}
end
- def scope_error
+ def minimum_scope_error
+ {
+ status: :error,
+ http_status: :unprocessable_entity,
+ message: 'Your GitHub access token does not have the correct scope to import.'
+ }
+ end
+
+ def collab_import_scope_error
{
status: :error,
http_status: :unprocessable_entity,
diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb
index 4067bce8d8d..4918c4e0082 100644
--- a/spec/workers/every_sidekiq_worker_spec.rb
+++ b/spec/workers/every_sidekiq_worker_spec.rb
@@ -247,21 +247,21 @@ RSpec.describe 'Every Sidekiq worker', feature_category: :shared do
'Geo::VerificationStateBackfillWorker' => false,
'Geo::VerificationTimeoutWorker' => false,
'Geo::VerificationWorker' => 3,
- 'Gitlab::BitbucketImport::AdvanceStageWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::FinishImportWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportIssuesWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportIssuesNotesWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportLfsObjectsWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportPullRequestsWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportPullRequestsNotesWorker' => 3,
- 'Gitlab::BitbucketImport::Stage::ImportRepositoryWorker' => 3,
- 'Gitlab::BitbucketServerImport::AdvanceStageWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::FinishImportWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::ImportLfsObjectsWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::ImportNotesWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::ImportPullRequestsWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::ImportRepositoryWorker' => 3,
- 'Gitlab::BitbucketServerImport::Stage::ImportUsersWorker' => 3,
+ 'Gitlab::BitbucketImport::AdvanceStageWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::FinishImportWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportIssuesWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportIssuesNotesWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportLfsObjectsWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportPullRequestsWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportPullRequestsNotesWorker' => 6,
+ 'Gitlab::BitbucketImport::Stage::ImportRepositoryWorker' => 6,
+ 'Gitlab::BitbucketServerImport::AdvanceStageWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::FinishImportWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::ImportLfsObjectsWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::ImportNotesWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::ImportPullRequestsWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::ImportRepositoryWorker' => 6,
+ 'Gitlab::BitbucketServerImport::Stage::ImportUsersWorker' => 6,
'Gitlab::GithubImport::AdvanceStageWorker' => 6,
'Gitlab::GithubImport::Attachments::ImportReleaseWorker' => 5,
'Gitlab::GithubImport::Attachments::ImportNoteWorker' => 5,
@@ -297,14 +297,14 @@ RSpec.describe 'Every Sidekiq worker', feature_category: :shared do
'Gitlab::GithubGistsImport::ImportGistWorker' => 5,
'Gitlab::GithubGistsImport::StartImportWorker' => 5,
'Gitlab::GithubGistsImport::FinishImportWorker' => 5,
- 'Gitlab::JiraImport::AdvanceStageWorker' => 5,
+ 'Gitlab::JiraImport::AdvanceStageWorker' => 6,
'Gitlab::JiraImport::ImportIssueWorker' => 5,
- 'Gitlab::JiraImport::Stage::FinishImportWorker' => 5,
- 'Gitlab::JiraImport::Stage::ImportAttachmentsWorker' => 5,
- 'Gitlab::JiraImport::Stage::ImportIssuesWorker' => 5,
- 'Gitlab::JiraImport::Stage::ImportLabelsWorker' => 5,
- 'Gitlab::JiraImport::Stage::ImportNotesWorker' => 5,
- 'Gitlab::JiraImport::Stage::StartImportWorker' => 5,
+ 'Gitlab::JiraImport::Stage::FinishImportWorker' => 6,
+ 'Gitlab::JiraImport::Stage::ImportAttachmentsWorker' => 6,
+ 'Gitlab::JiraImport::Stage::ImportIssuesWorker' => 6,
+ 'Gitlab::JiraImport::Stage::ImportLabelsWorker' => 6,
+ 'Gitlab::JiraImport::Stage::ImportNotesWorker' => 6,
+ 'Gitlab::JiraImport::Stage::StartImportWorker' => 6,
'GitlabPerformanceBarStatsWorker' => 3,
'GitlabSubscriptions::RefreshSeatsWorker' => 0,
'GitlabSubscriptions::AddOnPurchases::BulkRefreshUserAssignmentsWorker' => 0,