diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-02 12:07:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-02 12:07:27 +0300 |
commit | 7e8ecb5c00aae3b7072a5b8ff2c53db03c0bc579 (patch) | |
tree | e89c4b3d7af5db6805951e2847472b2e29e77bfd /spec | |
parent | f58c22e1cd553626dbfa4f347afb86544865cfbe (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/template_finder_spec.rb | 13 | ||||
-rw-r--r-- | spec/frontend/ide/stores/modules/file_templates/getters_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/jobs/components/table/job_table_app_spec.js | 46 | ||||
-rw-r--r-- | spec/lib/gitlab/database/partitioning_spec.rb | 18 | ||||
-rw-r--r-- | spec/requests/api/admin/batched_background_migrations_spec.rb | 21 | ||||
-rw-r--r-- | spec/requests/api/project_templates_spec.rb | 45 | ||||
-rw-r--r-- | spec/services/submodules/update_service_spec.rb | 84 |
7 files changed, 55 insertions, 174 deletions
diff --git a/spec/finders/template_finder_spec.rb b/spec/finders/template_finder_spec.rb index c466f533a61..c2b42cf0eb3 100644 --- a/spec/finders/template_finder_spec.rb +++ b/spec/finders/template_finder_spec.rb @@ -20,7 +20,6 @@ RSpec.describe TemplateFinder do :dockerfiles | 'Binary' :gitignores | 'Actionscript' :gitlab_ci_ymls | 'Android' - :metrics_dashboard_ymls | 'Default' end with_them do @@ -112,7 +111,6 @@ RSpec.describe TemplateFinder do :gitignores | described_class :gitlab_ci_ymls | described_class :licenses | ::LicenseTemplateFinder - :metrics_dashboard_ymls | described_class :issues | described_class :merge_requests | described_class end @@ -123,16 +121,6 @@ RSpec.describe TemplateFinder do it { is_expected.to be_a(expected_class) } it { expect(finder.project).to eq(project) } end - - context 'when metrics dashboard is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - subject(:finder) { described_class.build(:metrics_dashboard_ymls, project) } - - it { is_expected.to be_nil } - end end describe '#execute' do @@ -178,7 +166,6 @@ RSpec.describe TemplateFinder do :dockerfiles | 'Binary' :gitignores | 'Actionscript' :gitlab_ci_ymls | 'Android' - :metrics_dashboard_ymls | 'Default' end with_them do diff --git a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js index e237b167f96..02e0d55346e 100644 --- a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js @@ -5,7 +5,7 @@ import createState from '~/ide/stores/state'; describe('IDE file templates getters', () => { describe('templateTypes', () => { it('returns list of template types', () => { - expect(getters.templateTypes().length).toBe(5); + expect(getters.templateTypes().length).toBe(4); }); }); diff --git a/spec/frontend/jobs/components/table/job_table_app_spec.js b/spec/frontend/jobs/components/table/job_table_app_spec.js index 0e59e9ab5b6..032b83ca22b 100644 --- a/spec/frontend/jobs/components/table/job_table_app_spec.js +++ b/spec/frontend/jobs/components/table/job_table_app_spec.js @@ -60,14 +60,8 @@ describe('Job table app', () => { handler = successHandler, countHandler = countSuccessHandler, mountFn = shallowMount, - data = {}, } = {}) => { wrapper = mountFn(JobsTableApp, { - data() { - return { - ...data, - }; - }, provide: { fullPath: projectPath, }, @@ -108,34 +102,28 @@ describe('Job table app', () => { }); it('should refetch jobs query on fetchJobsByStatus event', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findTabs().vm.$emit('fetchJobsByStatus'); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1); + expect(successHandler).toHaveBeenCalledTimes(2); }); it('avoids refetch jobs query when scope has not changed', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findTabs().vm.$emit('fetchJobsByStatus', null); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); }); it('should refetch jobs count query when the amount jobs and count do not match', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); // after applying filter a new count is fetched findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(2); // tab is switched to `finished`, no count await findTabs().vm.$emit('fetchJobsByStatus', ['FAILED', 'SUCCESS', 'CANCELED']); @@ -143,7 +131,7 @@ describe('Job table app', () => { // tab is switched back to `all`, the old filter count has to be overwritten with new count await findTabs().vm.$emit('fetchJobsByStatus', null); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(2); + expect(countSuccessHandler).toHaveBeenCalledTimes(3); }); describe('when infinite scrolling is triggered', () => { @@ -261,25 +249,21 @@ describe('Job table app', () => { it('refetches jobs query when filtering', async () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1); + expect(successHandler).toHaveBeenCalledTimes(2); }); it('refetches jobs count query when filtering', async () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(2); }); it('shows raw text warning when user inputs raw text', async () => { @@ -292,14 +276,14 @@ describe('Job table app', () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); + expect(successHandler).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', ['raw text']); expect(createAlert).toHaveBeenCalledWith(expectedWarning); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); }); it('updates URL query string when filtering jobs by status', async () => { diff --git a/spec/lib/gitlab/database/partitioning_spec.rb b/spec/lib/gitlab/database/partitioning_spec.rb index e654cb65452..8724716dd3d 100644 --- a/spec/lib/gitlab/database/partitioning_spec.rb +++ b/spec/lib/gitlab/database/partitioning_spec.rb @@ -112,6 +112,24 @@ RSpec.describe Gitlab::Database::Partitioning, feature_category: :database do end end + context 'without ci database' do + it 'only creates partitions for main database' do + skip_if_database_exists(:ci) + + allow(Gitlab::Database::Partitioning::PartitionManager).to receive(:new).and_call_original + + # Also, in the case where `ci` database is shared with `main` database, + # check that we do not run PartitionManager again for ci connection as + # that is redundant. + expect(Gitlab::Database::Partitioning::PartitionManager).not_to receive(:new) + .with(anything, connection: ci_connection).and_call_original + + expect { described_class.sync_partitions(models) } + .to change { find_partitions(table_names.first, conn: main_connection).size }.from(0) + .and change { find_partitions(table_names.last, conn: main_connection).size }.from(0) + end + end + context 'when no partitioned models are given' do it 'manages partitions for each registered model' do described_class.register_models([models.first]) diff --git a/spec/requests/api/admin/batched_background_migrations_spec.rb b/spec/requests/api/admin/batched_background_migrations_spec.rb index e88fba3fbe7..180b6c7abd6 100644 --- a/spec/requests/api/admin/batched_background_migrations_spec.rb +++ b/spec/requests/api/admin/batched_background_migrations_spec.rb @@ -50,6 +50,27 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations, feature_category: :datab show_migration end + + context 'when migration has completed jobs' do + let(:migration) do + Gitlab::Database::SharedModel.using_connection(ci_model.connection) do + create(:batched_background_migration, :active, total_tuple_count: 100) + end + end + + let!(:batched_job) do + Gitlab::Database::SharedModel.using_connection(ci_model.connection) do + create(:batched_background_migration_job, :succeeded, batched_migration: migration, batch_size: 8) + end + end + + it 'calculates the progress using the CI database' do + show_migration + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['progress']).to eq(8) + end + end end context 'when the database name does not exist' do diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb index 91e5ed76c37..e1d156afd54 100644 --- a/spec/requests/api/project_templates_spec.rb +++ b/spec/requests/api/project_templates_spec.rb @@ -63,27 +63,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management expect(json_response).to satisfy_one { |template| template['key'] == 'mit' } end - it 'returns metrics_dashboard_ymls' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls") - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to include_pagination_headers - expect(response).to match_response_schema('public_api/v4/template_list') - expect(json_response).to satisfy_one { |template| template['key'] == 'Default' } - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns 400 bad request like other unknown types' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls") - - expect(response).to have_gitlab_http_status(:bad_request) - end - end - it 'returns issue templates' do get api("/projects/#{private_project.id}/templates/issues", developer) @@ -176,26 +155,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management expect(json_response['name']).to eq('Android') end - it 'returns a specific metrics_dashboard_yml' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default") - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('public_api/v4/template') - expect(json_response['name']).to eq('Default') - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns 400 bad request like other unknown types' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default") - - expect(response).to have_gitlab_http_status(:bad_request) - end - end - it 'returns a specific license' do get api("/projects/#{public_project.id}/templates/licenses/mit") @@ -256,10 +215,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management subject { get api("/projects/#{url_encoded_path}/templates/gitlab_ci_ymls/Android") } end - it_behaves_like 'accepts project paths with dots' do - subject { get api("/projects/#{url_encoded_path}/templates/metrics_dashboard_ymls/Default") } - end - shared_examples 'path traversal attempt' do |template_type| it 'rejects invalid filenames' do get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea") diff --git a/spec/services/submodules/update_service_spec.rb b/spec/services/submodules/update_service_spec.rb index aeaf8ec1c7b..b4282b2a89b 100644 --- a/spec/services/submodules/update_service_spec.rb +++ b/spec/services/submodules/update_service_spec.rb @@ -53,82 +53,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end context 'validations' do - context 'when submodule' do - context 'is empty' do - let(:submodule) { '' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is not present' do - let(:submodule) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is invalid' do - let(:submodule) { 'VERSION' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - - context 'does not exist' do - let(:submodule) { 'non-existent-submodule' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - - context 'has traversal path' do - let(:submodule) { '../six' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - end - - context 'commit_sha' do - context 'is empty' do - let(:commit_sha) { '' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is not present' do - let(:commit_sha) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is invalid' do - let(:commit_sha) { '1' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is the same as the current ref' do - let(:commit_sha) { current_sha } - - it_behaves_like 'returns error result' do - let(:error_message) { "The submodule #{submodule} is already at #{commit_sha}" } - end - end - end - context 'branch_name' do context 'is empty' do let(:branch_name) { '' } @@ -138,14 +62,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end end - context 'is not present' do - let(:branch_name) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - context 'does not exist' do let(:branch_name) { 'non/existent-branch' } |