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>2023-09-06 21:09:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-06 21:09:15 +0300
commitf011d78ffe71ec6778c8eb9ad981a6dbadd3a4dc (patch)
treeb1a3daf03bbbdc560c1ab74d702ef671c8f13dfe /spec
parent74739c4b9e2ced14233eaeee221c5472589d26cd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/search/sidebar/components/app_spec.js17
-rw-r--r--spec/frontend/super_sidebar/components/pinned_section_spec.js29
-rw-r--r--spec/lib/constraints/activity_pub_constrainer_spec.rb31
-rw-r--r--spec/lib/gitlab/ci/variables/builder_spec.rb14
-rw-r--r--spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb35
-rw-r--r--spec/models/ci/build_spec.rb8
-rw-r--r--spec/support/rspec_order_todo.yml1
-rw-r--r--spec/support/shared_examples/mailers/notify_shared_examples.rb8
8 files changed, 117 insertions, 26 deletions
diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js
index 31263a4365c..61a87af476e 100644
--- a/spec/frontend/search/sidebar/components/app_spec.js
+++ b/spec/frontend/search/sidebar/components/app_spec.js
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
// eslint-disable-next-line no-restricted-imports
import Vuex from 'vuex';
+import { SEARCH_TYPE_ZOEKT, SEARCH_TYPE_ADVANCED } from '~/search/sidebar/constants';
import { MOCK_QUERY } from 'jest/search/mock_data';
import GlobalSearchSidebar from '~/search/sidebar/components/app.vue';
import IssuesFilters from '~/search/sidebar/components/issues_filters.vue';
@@ -60,7 +61,7 @@ describe('GlobalSearchSidebar', () => {
`('with sidebar $scope scope:', ({ scope, filter }) => {
beforeEach(() => {
getterSpies.currentScope = jest.fn(() => scope);
- createComponent({ urlQuery: { scope } });
+ createComponent({ urlQuery: { scope }, searchType: SEARCH_TYPE_ADVANCED });
});
it(`shows filter ${filter.name.replace('find', '')}`, () => {
@@ -68,13 +69,23 @@ describe('GlobalSearchSidebar', () => {
});
});
- describe('with sidebar $scope scope:', () => {
+ describe('filters for blobs will not load if zoekt is enabled', () => {
+ beforeEach(() => {
+ createComponent({ urlQuery: { scope: 'blobs' }, searchType: SEARCH_TYPE_ZOEKT });
+ });
+
+ it("doesn't render blobs filters", () => {
+ expect(findBlobsFilters().exists()).toBe(false);
+ });
+ });
+
+ describe('with sidebar scope: projects', () => {
beforeEach(() => {
getterSpies.currentScope = jest.fn(() => 'projects');
createComponent({ urlQuery: { scope: 'projects' } });
});
- it(`shows filter ProjectsFilters}`, () => {
+ it(`shows filter ProjectsFilters`, () => {
expect(findProjectsFilters().exists()).toBe(true);
});
});
diff --git a/spec/frontend/super_sidebar/components/pinned_section_spec.js b/spec/frontend/super_sidebar/components/pinned_section_spec.js
index 00cc7cf29c9..fe1653f1177 100644
--- a/spec/frontend/super_sidebar/components/pinned_section_spec.js
+++ b/spec/frontend/super_sidebar/components/pinned_section_spec.js
@@ -87,4 +87,33 @@ describe('PinnedSection component', () => {
});
});
});
+
+ describe('ambiguous settings names', () => {
+ it('get renamed to be unambiguous', () => {
+ createWrapper({
+ items: [
+ { title: 'CI/CD', id: 'ci_cd' },
+ { title: 'Merge requests', id: 'merge_request_settings' },
+ { title: 'Monitor', id: 'monitor' },
+ { title: 'Repository', id: 'repository' },
+ { title: 'Repository', id: 'code' },
+ { title: 'Something else', id: 'not_a_setting' },
+ ],
+ });
+
+ expect(
+ wrapper
+ .findComponent(MenuSection)
+ .props('item')
+ .items.map((i) => i.title),
+ ).toEqual([
+ 'CI/CD settings',
+ 'Merge requests settings',
+ 'Monitor settings',
+ 'Repository settings',
+ 'Repository',
+ 'Something else',
+ ]);
+ });
+ });
});
diff --git a/spec/lib/constraints/activity_pub_constrainer_spec.rb b/spec/lib/constraints/activity_pub_constrainer_spec.rb
new file mode 100644
index 00000000000..8a37beb4d0f
--- /dev/null
+++ b/spec/lib/constraints/activity_pub_constrainer_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Constraints::ActivityPubConstrainer, feature_category: :groups_and_projects do
+ subject(:constraint) { described_class.new }
+
+ describe '#matches?' do
+ subject { constraint.matches?(request) }
+
+ let(:request) { ActionDispatch::Request.new(headers) }
+
+ ['application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'application/activity+json'].each do |mime|
+ context "when mime is #{mime}" do
+ let(:headers) { { 'HTTP_ACCEPT' => mime } }
+
+ it 'matches the header' do
+ is_expected.to be_truthy
+ end
+ end
+ end
+
+ context 'when Accept header is missing' do
+ let(:headers) { {} }
+
+ it 'does not match' do
+ is_expected.to be_falsey
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/ci/variables/builder_spec.rb b/spec/lib/gitlab/ci/variables/builder_spec.rb
index 041a186e133..af745c75f42 100644
--- a/spec/lib/gitlab/ci/variables/builder_spec.rb
+++ b/spec/lib/gitlab/ci/variables/builder_spec.rb
@@ -171,20 +171,6 @@ RSpec.describe Gitlab::Ci::Variables::Builder, :clean_gitlab_redis_cache, featur
it { expect(subject.to_runner_variables).to eq(predefined_variables) }
- context 'when support_ci_environment_variables_in_job_rules feature flag is disabled' do
- before do
- stub_feature_flags(support_ci_environment_variables_in_job_rules: false)
-
- # This is a bug. `CI_ENVIRONMENT_NAME` should be expanded.
- predefined_variables.find { |var| var[:key] == 'CI_ENVIRONMENT_NAME' }[:value] = 'review/$CI_COMMIT_REF_NAME'
- predefined_variables.delete_if do |var|
- %w[CI_ENVIRONMENT_ACTION CI_ENVIRONMENT_TIER CI_ENVIRONMENT_URL].include?(var[:key])
- end
- end
-
- it { expect(subject.to_runner_variables).to eq(predefined_variables) }
- end
-
context 'variables ordering' do
def var(name, value)
{ key: name, value: value.to_s, public: true, masked: false }
diff --git a/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb b/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb
new file mode 100644
index 00000000000..0e1f6cd9b69
--- /dev/null
+++ b/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe UpdatePackageMetadataSyncSetting, feature_category: :software_composition_analysis do
+ let(:settings) { table(:application_settings) }
+ let(:fully_enabled_sync_setting) { [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
+
+ describe "#up" do
+ context 'with default value' do
+ let(:fully_disabled_sync) { [] }
+
+ it 'updates setting' do
+ settings.create!(package_metadata_purl_types: fully_disabled_sync)
+
+ migrate!
+
+ expect(ApplicationSetting.last.package_metadata_purl_types).to eq(fully_enabled_sync_setting)
+ end
+ end
+
+ context 'with custom value' do
+ let(:partially_enabled_sync) { [1, 2, 3, 4, 5] }
+
+ it 'does not change setting' do
+ settings.create!(package_metadata_purl_types: partially_enabled_sync)
+
+ migrate!
+
+ expect(ApplicationSetting.last.package_metadata_purl_types).to eq(partially_enabled_sync)
+ end
+ end
+ end
+end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 15f31d98d98..8adbd27cd1c 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -2670,14 +2670,6 @@ RSpec.describe Ci::Build, feature_category: :continuous_integration, factory_def
end
it_behaves_like 'containing environment variables'
-
- context 'when support_ci_environment_variables_in_job_rules feature flag is disabled' do
- before do
- stub_feature_flags(support_ci_environment_variables_in_job_rules: false)
- end
-
- it_behaves_like 'containing environment variables'
- end
end
context 'when an URL was set' do
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 6ac1a27745f..0d84b9829b1 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -19,7 +19,6 @@
- './ee/spec/controllers/admin/elasticsearch_controller_spec.rb'
- './ee/spec/controllers/admin/emails_controller_spec.rb'
- './ee/spec/controllers/admin/geo/nodes_controller_spec.rb'
-- './ee/spec/controllers/admin/geo/projects_controller_spec.rb'
- './ee/spec/controllers/admin/geo/settings_controller_spec.rb'
- './ee/spec/controllers/admin/groups_controller_spec.rb'
- './ee/spec/controllers/admin/impersonations_controller_spec.rb'
diff --git a/spec/support/shared_examples/mailers/notify_shared_examples.rb b/spec/support/shared_examples/mailers/notify_shared_examples.rb
index cf1ab7697ab..987060d73b9 100644
--- a/spec/support/shared_examples/mailers/notify_shared_examples.rb
+++ b/spec/support/shared_examples/mailers/notify_shared_examples.rb
@@ -54,6 +54,14 @@ RSpec.shared_examples 'an email with X-GitLab headers containing IDs' do
expect(subject.header["X-GitLab-#{model.class.name}-IID"]).to eq nil
end
end
+
+ it 'has X-GitLab-*-State header if model has state defined' do
+ if model.respond_to?(:state)
+ is_expected.to have_header "X-GitLab-#{model.class.name}-State", model.state.to_s
+ else
+ expect(subject.header["X-GitLab-#{model.class.name}-State"]).to eq nil
+ end
+ end
end
RSpec.shared_examples 'an email with X-GitLab headers containing project details' do