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-02-08 06:10:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-08 06:10:25 +0300
commitd8b3ba4b19f12a88a2aa6881bf770f9713a68d32 (patch)
tree2fc2ecd02a7edae8be4502240a09d709b6e8bb6a /spec
parent9f1ce98c1d456b962fc43ec99180e042592fa307 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/ci/runners.rb2
-rw-r--r--spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js31
-rw-r--r--spec/models/ci/runner_spec.rb24
-rw-r--r--spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb86
4 files changed, 70 insertions, 73 deletions
diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb
index 860322075e2..1f4a8eebca2 100644
--- a/spec/factories/ci/runners.rb
+++ b/spec/factories/ci/runners.rb
@@ -58,7 +58,7 @@ FactoryBot.define do
end
end
- trait :created_in_ui do
+ trait :created_via_ui do
legacy_registered { false }
end
diff --git a/spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js b/spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
index 1ad6d043399..63371b1492b 100644
--- a/spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
+++ b/spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
@@ -4,6 +4,7 @@ import { nextTick } from 'vue';
import { TEST_HOST } from 'spec/test_constants';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
+import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
const TEST_IMAGE_SIZE = 7;
const TEST_BREAKPOINT = 5;
@@ -16,10 +17,13 @@ const createUser = (id) => ({
web_url: `${TEST_HOST}/${id}`,
avatar_url: `${TEST_HOST}/${id}/avatar`,
});
+
const createList = (n) =>
Array(n)
.fill(1)
.map((x, id) => createUser(id));
+const createListCamelCase = (n) =>
+ createList(n).map((user) => convertObjectPropsToCamelCase(user, { deep: true }));
describe('UserAvatarList', () => {
let props;
@@ -75,14 +79,14 @@ describe('UserAvatarList', () => {
props.breakpoint = 0;
});
- it('renders avatars', () => {
+ const linkProps = () =>
+ wrapper.findAllComponents(UserAvatarLink).wrappers.map((x) => x.props());
+
+ it('renders avatars when user has snake_case attributes', () => {
const items = createList(20);
factory({ propsData: { items } });
- const links = wrapper.findAllComponents(UserAvatarLink);
- const linkProps = links.wrappers.map((x) => x.props());
-
- expect(linkProps).toEqual(
+ expect(linkProps()).toEqual(
items.map((x) =>
expect.objectContaining({
linkHref: x.web_url,
@@ -94,6 +98,23 @@ describe('UserAvatarList', () => {
),
);
});
+
+ it('renders avatars when user has camelCase attributes', () => {
+ const items = createListCamelCase(20);
+ factory({ propsData: { items } });
+
+ expect(linkProps()).toEqual(
+ items.map((x) =>
+ expect.objectContaining({
+ linkHref: x.webUrl,
+ imgSrc: x.avatarUrl,
+ imgAlt: x.name,
+ tooltipText: x.name,
+ imgSize: TEST_IMAGE_SIZE,
+ }),
+ ),
+ );
+ });
});
describe('with breakpoint and length equal to breakpoint', () => {
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index c75d1faf48f..95b87c26c01 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -1737,6 +1737,24 @@ RSpec.describe Ci::Runner, feature_category: :runner do
end
end
+ describe '#short_sha' do
+ subject(:short_sha) { runner.short_sha }
+
+ context 'when registered via command-line' do
+ let(:runner) { create(:ci_runner) }
+
+ specify { expect(runner.token).not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) }
+ it { is_expected.not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) }
+ end
+
+ context 'when creating new runner via UI' do
+ let(:runner) { create(:ci_runner, :created_via_ui) }
+
+ specify { expect(runner.token).to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) }
+ it { is_expected.not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) }
+ end
+ end
+
describe '#token' do
subject(:token) { runner.token }
@@ -1746,8 +1764,8 @@ RSpec.describe Ci::Runner, feature_category: :runner do
it { is_expected.not_to start_with('glrt-') }
end
- context 'when runner is created in UI' do
- let(:runner) { create(:ci_runner, :created_in_ui) }
+ context 'when runner is created via UI' do
+ let(:runner) { create(:ci_runner, :created_via_ui) }
it { is_expected.to start_with('glrt-') }
end
@@ -1986,7 +2004,7 @@ RSpec.describe Ci::Runner, feature_category: :runner do
end
context 'when runner created via UI' do
- let(:runner) { create(:ci_runner, :created_in_ui) }
+ let(:runner) { create(:ci_runner, :created_via_ui) }
it { is_expected.to eq true }
end
diff --git a/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb b/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
index 8565299b9b7..a28a552746f 100644
--- a/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
+++ b/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile, :aggregate_failures do
+RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile, :aggregate_failures, feature_category: :importers do
let(:remote_url) { 'https://external.file.path/file.tar.gz' }
let(:params) { { remote_import_url: remote_url } }
@@ -40,23 +40,19 @@ RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile,
end
end
- context 'when import_project_from_remote_file_s3 is enabled' do
- before do
- stub_feature_flags(import_project_from_remote_file_s3: true)
- end
-
- context 'when the HTTP request fail to recover the headers' do
- it 'adds the error message' do
- expect(Gitlab::HTTP)
- .to receive(:head)
- .and_raise(StandardError, 'request invalid')
+ context 'when the HTTP request fails to recover the headers' do
+ it 'adds the error message' do
+ expect(Gitlab::HTTP)
+ .to receive(:head)
+ .and_raise(StandardError, 'request invalid')
- expect(subject).not_to be_valid
- expect(subject.errors.full_messages)
- .to include('Failed to retrive headers: request invalid')
- end
+ expect(subject).not_to be_valid
+ expect(subject.errors.full_messages)
+ .to include('Failed to retrive headers: request invalid')
end
+ end
+ context 'when request is not from an S3 server' do
it 'validates the remote content-length' do
stub_headers_for(remote_url, { 'content-length' => 11.gigabytes })
@@ -72,57 +68,19 @@ RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile,
expect(subject.errors.full_messages)
.to include("Content type 'unknown' not allowed. (Allowed: application/gzip, application/x-tar, application/x-gzip)")
end
-
- context 'when trying to import from AWS S3' do
- it 'adds an error suggesting to use `projects/remote-import-s3`' do
- stub_headers_for(
- remote_url,
- 'Server' => 'AmazonS3',
- 'x-amz-request-id' => 'some-id'
- )
-
- expect(subject).not_to be_valid
- expect(subject.errors.full_messages)
- .to include('To import from AWS S3 use `projects/remote-import-s3`')
- end
- end
end
- context 'when import_project_from_remote_file_s3 is disabled' do
- before do
- stub_feature_flags(import_project_from_remote_file_s3: false)
- end
-
- context 'when trying to import from AWS S3' do
- it 'does not validate the remote content-length or content-type' do
- stub_headers_for(
- remote_url,
- 'Server' => 'AmazonS3',
- 'x-amz-request-id' => 'some-id',
- 'content-length' => 11.gigabytes,
- 'content-type' => 'unknown'
- )
-
- expect(subject).to be_valid
- end
- end
-
- context 'when NOT trying to import from AWS S3' do
- it 'validates content-length and content-type' do
- stub_headers_for(
- remote_url,
- 'Server' => 'NOT AWS S3',
- 'content-length' => 11.gigabytes,
- 'content-type' => 'unknown'
- )
-
- expect(subject).not_to be_valid
-
- expect(subject.errors.full_messages)
- .to include("Content type 'unknown' not allowed. (Allowed: application/gzip, application/x-tar, application/x-gzip)")
- expect(subject.errors.full_messages)
- .to include('Content length is too big (should be at most 10 GB)')
- end
+ context 'when request is from an S3 server' do
+ it 'does not validate the remote content-length or content-type' do
+ stub_headers_for(
+ remote_url,
+ 'Server' => 'AmazonS3',
+ 'x-amz-request-id' => 'some-id',
+ 'content-length' => 11.gigabytes,
+ 'content-type' => 'unknown'
+ )
+
+ expect(subject).to be_valid
end
end
end