diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-13 00:13:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-13 00:13:31 +0300 |
commit | 42a4fe5b394e010b3f512a5a138359618295193b (patch) | |
tree | 9552d72a17537c74f813d489e822e09e91d1dc3c /spec | |
parent | 6121ad5af38294f12db08f13aec122c3dbef583a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/projects.rb | 12 | ||||
-rw-r--r-- | spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js | 18 | ||||
-rw-r--r-- | spec/helpers/artifacts_helper_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/database/postgres_sequences_spec.rb | 35 | ||||
-rw-r--r-- | spec/models/ci/catalog/resource_spec.rb | 47 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 15 | ||||
-rw-r--r-- | spec/requests/explore/catalog_controller_spec.rb | 27 | ||||
-rw-r--r-- | spec/services/ci/process_sync_events_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/workers/ci/catalog/resources/process_sync_events_worker_spec.rb | 16 |
9 files changed, 81 insertions, 106 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 4da7dcba763..a2848bd0256 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -608,4 +608,16 @@ FactoryBot.define do path { 'gitlab-profile' } files { { 'README.md' => 'Hello World' } } end + + trait :with_code_suggestions_enabled do + after(:create) do |project| + project.project_setting.update!(code_suggestions: true) + end + end + + trait :with_code_suggestions_disabled do + after(:create) do |project| + project.project_setting.update!(code_suggestions: false) + end + end end diff --git a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js index d44886a4f95..36f27d1781e 100644 --- a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js +++ b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js @@ -22,11 +22,12 @@ import { I18N_FETCH_ERROR, INITIAL_CURRENT_PAGE, I18N_BULK_DELETE_ERROR, - SELECTED_ARTIFACTS_MAX_COUNT, } from '~/ci/artifacts/constants'; import { totalArtifactsSizeForJob } from '~/ci/artifacts/utils'; import { createAlert } from '~/alert'; +const jobArtifactsCountLimit = 100; + jest.mock('~/alert'); Vue.use(VueApollo); @@ -127,10 +128,10 @@ describe('JobArtifactsTable component', () => { .map((jobNode) => jobNode.artifacts.nodes.map((artifactNode) => artifactNode.id)) .reduce((artifacts, jobArtifacts) => artifacts.concat(jobArtifacts)); - const maxSelectedArtifacts = new Array(SELECTED_ARTIFACTS_MAX_COUNT).fill('artifact-id'); + const maxSelectedArtifacts = new Array(jobArtifactsCountLimit).fill('artifact-id'); const maxSelectedArtifactsIncludingCurrentPage = [ ...allArtifacts, - ...new Array(SELECTED_ARTIFACTS_MAX_COUNT - allArtifacts.length).fill('artifact-id'), + ...new Array(jobArtifactsCountLimit - allArtifacts.length).fill('artifact-id'), ]; const createComponent = ({ @@ -151,6 +152,7 @@ describe('JobArtifactsTable component', () => { projectPath: 'project/path', projectId, canDestroyArtifacts, + jobArtifactsCountLimit, }, mocks: { $toast: { @@ -665,7 +667,7 @@ describe('JobArtifactsTable component', () => { describe('select all checkbox respects selected artifacts limit', () => { describe('when selecting all visible artifacts would exceed the limit', () => { - const selectedArtifactsLength = SELECTED_ARTIFACTS_MAX_COUNT - 1; + const selectedArtifactsLength = jobArtifactsCountLimit - 1; beforeEach(async () => { createComponent({ @@ -687,9 +689,7 @@ describe('JobArtifactsTable component', () => { await nextTick(); expect(findSelectAllCheckboxChecked()).toBe(true); - expect(findBulkDelete().props('selectedArtifacts')).toHaveLength( - SELECTED_ARTIFACTS_MAX_COUNT, - ); + expect(findBulkDelete().props('selectedArtifacts')).toHaveLength(jobArtifactsCountLimit); expect(findBulkDelete().props('selectedArtifacts')).not.toContain( allArtifacts[allArtifacts.length - 1], ); @@ -748,7 +748,7 @@ describe('JobArtifactsTable component', () => { it('deselects all artifacts when toggled', async () => { expect(findBulkDelete().props('selectedArtifacts')).toHaveLength( - SELECTED_ARTIFACTS_MAX_COUNT, + jobArtifactsCountLimit, ); toggleSelectAllCheckbox(); @@ -757,7 +757,7 @@ describe('JobArtifactsTable component', () => { expect(findSelectAllCheckboxChecked()).toBe(false); expect(findBulkDelete().props('selectedArtifacts')).toHaveLength( - SELECTED_ARTIFACTS_MAX_COUNT - allArtifacts.length, + jobArtifactsCountLimit - allArtifacts.length, ); }); }); diff --git a/spec/helpers/artifacts_helper_spec.rb b/spec/helpers/artifacts_helper_spec.rb index 30f9421954e..ed400ad4111 100644 --- a/spec/helpers/artifacts_helper_spec.rb +++ b/spec/helpers/artifacts_helper_spec.rb @@ -17,7 +17,8 @@ RSpec.describe ArtifactsHelper, feature_category: :build_artifacts do it 'returns expected data' do expect(subject).to include({ project_path: project.full_path, - project_id: project.id + project_id: project.id, + job_artifacts_count_limit: 100 }) end diff --git a/spec/lib/gitlab/database/postgres_sequences_spec.rb b/spec/lib/gitlab/database/postgres_sequences_spec.rb new file mode 100644 index 00000000000..2373edaea18 --- /dev/null +++ b/spec/lib/gitlab/database/postgres_sequences_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Database::PostgresSequence, type: :model, feature_category: :database do + # PostgresSequence does not `behaves_like 'a postgres model'` because it does not correspond 1-1 with a single entry + # in pg_class + let(:schema) { ActiveRecord::Base.connection.current_schema } + let(:table_name) { '_test_table' } + let(:table_name_without_sequence) { '_test_table_without_sequence' } + + before do + ActiveRecord::Base.connection.execute(<<~SQL) + CREATE TABLE #{table_name} ( + id bigserial PRIMARY KEY NOT NULL + ); + + CREATE TABLE #{table_name_without_sequence} ( + id bigint PRIMARY KEY NOT NULL + ); + SQL + end + + describe '#by_table_name' do + context 'when table does not have a sequence' do + it 'returns an empty collection' do + expect(described_class.by_table_name(table_name_without_sequence)).to be_empty + end + end + + it 'returns the sequence for a given table' do + expect(described_class.by_table_name(table_name).first[:table_name]).to eq(table_name) + end + end +end diff --git a/spec/models/ci/catalog/resource_spec.rb b/spec/models/ci/catalog/resource_spec.rb index 047ba135cd5..8ed7369e3d7 100644 --- a/spec/models/ci/catalog/resource_spec.rb +++ b/spec/models/ci/catalog/resource_spec.rb @@ -212,53 +212,6 @@ RSpec.describe Ci::Catalog::Resource, feature_category: :pipeline_composition do end end end - - context 'when FF `ci_process_catalog_resource_sync_events` is disabled' do - before do - stub_feature_flags(ci_process_catalog_resource_sync_events: false) - end - - context 'when the catalog resource is created' do - let(:resource) { build(:ci_catalog_resource, project: project) } - - it 'updates the catalog resource columns to match the project' do - resource.save! - resource.reload - - expect(resource.name).to eq(project.name) - expect(resource.description).to eq(project.description) - expect(resource.visibility_level).to eq(project.visibility_level) - end - end - - context 'when the project is updated' do - let_it_be(:resource) { create(:ci_catalog_resource, project: project) } - - context 'when project name is updated' do - it 'updates the catalog resource name to match' do - project.update!(name: 'New name') - - expect(resource.reload.name).to eq(project.name) - end - end - - context 'when project description is updated' do - it 'updates the catalog resource description to match' do - project.update!(description: 'New description') - - expect(resource.reload.description).to eq(project.description) - end - end - - context 'when project visibility_level is updated' do - it 'updates the catalog resource visibility_level to match' do - project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) - - expect(resource.reload.visibility_level).to eq(project.visibility_level) - end - end - end - end end describe '#update_latest_released_at! triggered in model callbacks' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a58856afe02..c256c4f10f8 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -8956,21 +8956,6 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr project.update!(path: 'path') end end - - context 'when FF `ci_process_catalog_resource_sync_events` is disabled' do - before do - stub_feature_flags(ci_process_catalog_resource_sync_events: false) - end - - it 'does not enqueue Ci::Catalog::Resources::ProcessSyncEventsWorker' do - expect(Ci::Catalog::Resources::ProcessSyncEventsWorker).not_to receive(:perform_async) - - project.update!( - name: 'New name', - description: 'New description', - visibility_level: Gitlab::VisibilityLevel::INTERNAL) - end - end end context 'when the project does not have a catalog resource' do diff --git a/spec/requests/explore/catalog_controller_spec.rb b/spec/requests/explore/catalog_controller_spec.rb index 051379c9641..e75b0bba5a6 100644 --- a/spec/requests/explore/catalog_controller_spec.rb +++ b/spec/requests/explore/catalog_controller_spec.rb @@ -3,7 +3,10 @@ require 'spec_helper' RSpec.describe Explore::CatalogController, feature_category: :pipeline_composition do - let_it_be(:catalog_resource) { create(:ci_catalog_resource, state: :published) } + let_it_be(:namespace) { create(:group) } + let_it_be(:project) { create(:project, namespace: namespace) } + let_it_be(:catalog_resource) { create(:ci_catalog_resource, :published, project: project) } + let_it_be(:user) { create(:user) } before_all do @@ -34,17 +37,33 @@ RSpec.describe Explore::CatalogController, feature_category: :pipeline_compositi it_behaves_like 'basic get requests', :show context 'when rendering a draft catalog resource' do - it 'responds with 404' do - catalog_resource = create(:ci_catalog_resource, state: :draft) + it 'returns not found error' do + draft_catalog_resource = create(:ci_catalog_resource, state: :draft) - get explore_catalog_path(catalog_resource) + get explore_catalog_path(draft_catalog_resource) expect(response).to have_gitlab_http_status(:not_found) end end + + context 'when rendering a published catalog resource' do + it 'returns success response' do + get explore_catalog_path(catalog_resource) + + expect(response).to have_gitlab_http_status(:success) + end + end end describe 'GET #index' do + let(:subject) { get explore_catalog_index_path } + it_behaves_like 'basic get requests', :index + + it_behaves_like 'internal event tracking' do + let(:namespace) { user.namespace } + let(:project) { nil } + let(:event) { 'unique_users_visiting_ci_catalog' } + end end end diff --git a/spec/services/ci/process_sync_events_service_spec.rb b/spec/services/ci/process_sync_events_service_spec.rb index 48b70eb38c9..cea5eec294e 100644 --- a/spec/services/ci/process_sync_events_service_spec.rb +++ b/spec/services/ci/process_sync_events_service_spec.rb @@ -212,20 +212,6 @@ RSpec.describe Ci::ProcessSyncEventsService, feature_category: :continuous_integ execute end - - context 'when FF `ci_process_catalog_resource_sync_events` is disabled' do - before do - stub_feature_flags(ci_process_catalog_resource_sync_events: false) - end - - it 'does not enqueue Ci::Catalog::Resources::ProcessSyncEventsWorker' do - stub_const("#{described_class}::BATCH_SIZE", 1) - - expect(Ci::Catalog::Resources::ProcessSyncEventsWorker).not_to receive(:perform_async) - - execute - end - end end # The `p_catalog_resource_sync_events` table does not enforce an FK on catalog_resource_id diff --git a/spec/workers/ci/catalog/resources/process_sync_events_worker_spec.rb b/spec/workers/ci/catalog/resources/process_sync_events_worker_spec.rb index fba8bb50a32..036cc54e9ba 100644 --- a/spec/workers/ci/catalog/resources/process_sync_events_worker_spec.rb +++ b/spec/workers/ci/catalog/resources/process_sync_events_worker_spec.rb @@ -48,21 +48,5 @@ RSpec.describe Ci::Catalog::Resources::ProcessSyncEventsWorker, feature_category perform end - - context 'when FF `ci_process_catalog_resource_sync_events` is disabled' do - before do - stub_feature_flags(ci_process_catalog_resource_sync_events: false) - end - - it 'does not process the sync events', :aggregate_failures do - expect(worker).not_to receive(:log_extra_metadata_on_done) - - expect { perform }.not_to change { Ci::Catalog::Resources::SyncEvent.status_pending.count } - - expect(resource.reload.name).to eq('Old Name') - expect(resource.reload.description).to be_nil - expect(resource.reload.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) - end - end end end |