diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-12 03:12:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-12 03:12:11 +0000 |
commit | f78f3d867871ce9ad79e5fcb8e4e3e8ffda37200 (patch) | |
tree | 5970d9f84231a66d2bb040fa50ce820b0d5de520 /spec | |
parent | 5e13b3a9e58a7b78e93b4aa5a12cc19bd6bca674 (diff) | |
download | gitlab-ce-f78f3d867871ce9ad79e5fcb8e4e3e8ffda37200.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/packages/group_packages_finder_spec.rb | 24 | ||||
-rw-r--r-- | spec/finders/packages/package_finder_spec.rb | 24 | ||||
-rw-r--r-- | spec/finders/packages/packages_finder_spec.rb | 25 | ||||
-rw-r--r-- | spec/lib/gitlab/diff/file_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/subscription_portal_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/packages/package_spec.rb | 51 | ||||
-rw-r--r-- | spec/presenters/blob_presenter_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/package_files_spec.rb | 28 | ||||
-rw-r--r-- | spec/services/clusters/cleanup/project_namespace_service_spec.rb | 13 | ||||
-rw-r--r-- | spec/services/clusters/cleanup/service_account_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers/test_env.rb | 2 | ||||
-rw-r--r-- | spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb | 19 |
12 files changed, 42 insertions, 174 deletions
diff --git a/spec/finders/packages/group_packages_finder_spec.rb b/spec/finders/packages/group_packages_finder_spec.rb index 7da1bfa58aa..3254c436674 100644 --- a/spec/finders/packages/group_packages_finder_spec.rb +++ b/spec/finders/packages/group_packages_finder_spec.rb @@ -160,30 +160,6 @@ RSpec.describe Packages::GroupPackagesFinder do end end - context 'with pipelines' do - let_it_be(:build_info_1) { create(:package_build_info, :with_pipeline, package: package1) } - let_it_be(:build_info_2) { create(:package_build_info, :with_pipeline, package: package2) } - - it 'preloads the pipelines' do - expect(::Packages::Package).to receive(:preload_pipelines).and_call_original - expect(::Packages::Package).not_to receive(:including_build_info) - - expect(subject).to match_array([package1, package2]) - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'includes the pipelines' do - expect(::Packages::Package).to receive(:including_build_info).and_call_original - expect(::Packages::Package).not_to receive(:preload_pipelines) - expect(subject).to match_array([package1, package2]) - end - end - end - it_behaves_like 'concerning versionless param' it_behaves_like 'concerning package statuses' end diff --git a/spec/finders/packages/package_finder_spec.rb b/spec/finders/packages/package_finder_spec.rb index dfa1a65b322..1b0c88a4771 100644 --- a/spec/finders/packages/package_finder_spec.rb +++ b/spec/finders/packages/package_finder_spec.rb @@ -32,29 +32,5 @@ RSpec.describe ::Packages::PackageFinder do expect { subject }.to raise_exception(ActiveRecord::RecordNotFound) end end - - context 'with pipelines' do - let_it_be(:build_info) { create(:package_build_info, :with_pipeline, package: maven_package) } - - it 'preloads the pipelines' do - expect(::Packages::Package).to receive(:preload_pipelines).and_call_original - expect(::Packages::Package).not_to receive(:including_build_info) - - expect(subject).to eq(maven_package) - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'includes the pipelines' do - expect(::Packages::Package).to receive(:including_build_info).and_call_original - expect(::Packages::Package).not_to receive(:preload_pipelines) - - expect(subject).to eq(maven_package) - end - end - end end end diff --git a/spec/finders/packages/packages_finder_spec.rb b/spec/finders/packages/packages_finder_spec.rb index 8d67c96e815..b72f4aab3ec 100644 --- a/spec/finders/packages/packages_finder_spec.rb +++ b/spec/finders/packages/packages_finder_spec.rb @@ -81,31 +81,6 @@ RSpec.describe ::Packages::PackagesFinder do it { is_expected.to match_array([conan_package, maven_package]) } end - context 'with pipelines' do - let_it_be(:build_info1) { create(:package_build_info, :with_pipeline, package: conan_package) } - let_it_be(:build_info2) { create(:package_build_info, :with_pipeline, package: maven_package) } - - it 'preloads the pipelines' do - expect(::Packages::Package).to receive(:preload_pipelines).and_call_original - expect(::Packages::Package).not_to receive(:including_build_info) - - expect(subject).to match_array([conan_package, maven_package]) - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'includes the pipelines' do - expect(::Packages::Package).to receive(:including_build_info).and_call_original - expect(::Packages::Package).not_to receive(:preload_pipelines) - - expect(subject).to match_array([conan_package, maven_package]) - end - end - end - it_behaves_like 'concerning versionless param' it_behaves_like 'concerning package statuses' end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index 31968034f8e..4b437397688 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -52,7 +52,7 @@ RSpec.describe Gitlab::Diff::File do end describe 'initialize' do - context 'when file is ipynb' do + context 'when file is ipynb with a change after transformation' do let(:commit) { project.commit("f6b7a707") } let(:diff) { commit.raw_diffs.first } let(:diff_file) { described_class.new(diff, diff_refs: commit.diff_refs, repository: project.repository) } @@ -77,6 +77,20 @@ RSpec.describe Gitlab::Diff::File do end end end + + context 'when file is ipynb, but there only changes that are removed' do + let(:commit) { project.commit("2b5ef814") } + let(:diff) { commit.raw_diffs.first } + let(:diff_file) { described_class.new(diff, diff_refs: commit.diff_refs, repository: project.repository) } + + before do + stub_feature_flags(jupyter_clean_diffs: true) + end + + it 'does not recreate the diff' do + expect(diff_file.diff.diff).to include('execution_count') + end + end end describe '#diff_lines' do diff --git a/spec/lib/gitlab/subscription_portal_spec.rb b/spec/lib/gitlab/subscription_portal_spec.rb index 4fa9ee7afb0..4be1c85f7c8 100644 --- a/spec/lib/gitlab/subscription_portal_spec.rb +++ b/spec/lib/gitlab/subscription_portal_spec.rb @@ -60,7 +60,7 @@ RSpec.describe ::Gitlab::SubscriptionPortal do :subscriptions_more_minutes_url | 'https://customers.staging.gitlab.com/buy_pipeline_minutes' :subscriptions_more_storage_url | 'https://customers.staging.gitlab.com/buy_storage' :subscriptions_manage_url | 'https://customers.staging.gitlab.com/subscriptions' - :subscriptions_plans_url | 'https://customers.staging.gitlab.com/plans' + :subscriptions_plans_url | 'https://about.gitlab.com/pricing/' :subscriptions_instance_review_url | 'https://customers.staging.gitlab.com/instance_review' :subscriptions_gitlab_plans_url | 'https://customers.staging.gitlab.com/gitlab_plans' end diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb index 3fca139fc12..6ee5219819c 100644 --- a/spec/models/packages/package_spec.rb +++ b/spec/models/packages/package_spec.rb @@ -962,33 +962,6 @@ RSpec.describe Packages::Package, type: :model do end end - describe '.load_pipelines' do - let_it_be(:package) { create(:maven_package) } - let_it_be(:build_info) { create(:package_build_info, :with_pipeline, package: package) } - - subject { described_class.load_pipelines } - - it 'uses preload', :aggregate_failures do - expect(described_class).to receive(:preload_pipelines).and_call_original - expect(described_class).not_to receive(:including_build_info) - - subject - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'uses includes', :aggregate_failures do - expect(described_class).to receive(:including_build_info).and_call_original - expect(described_class).not_to receive(:preload_pipelines) - - subject - end - end - end - describe '#versions' do let_it_be(:project) { create(:project) } let_it_be(:package) { create(:maven_package, project: project) } @@ -1002,30 +975,6 @@ RSpec.describe Packages::Package, type: :model do it 'does not return different packages' do expect(package.versions).not_to include(package3) end - - context 'with pipelines' do - let_it_be(:build_info) { create(:package_build_info, :with_pipeline, package: package2) } - - it 'preloads the pipelines' do - expect(::Packages::Package).to receive(:preload_pipelines).and_call_original - expect(::Packages::Package).not_to receive(:including_build_info) - - expect(package.versions).to contain_exactly(package2) - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'includes the pipelines' do - expect(::Packages::Package).to receive(:including_build_info).and_call_original - expect(::Packages::Package).not_to receive(:preload_pipelines) - - expect(package.versions).to contain_exactly(package2) - end - end - end end describe '#pipeline' do diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index f433074e7d4..d3a06bda782 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -126,6 +126,10 @@ RSpec.describe BlobPresenter do let(:blob) { repository.blob_at('f6b7a707', 'files/ipython/markdown-table.ipynb') } let(:git_blob) { blob.__getobj__ } + before do + allow(git_blob).to receive(:transformed_for_diff).and_return(true) + end + it 'uses md as the transformed language' do expect(Gitlab::Highlight).to receive(:highlight).with('files/ipython/markdown-table.ipynb', anything, plain: nil, language: 'md') diff --git a/spec/requests/api/package_files_spec.rb b/spec/requests/api/package_files_spec.rb index c170c151057..eb1f04d193e 100644 --- a/spec/requests/api/package_files_spec.rb +++ b/spec/requests/api/package_files_spec.rb @@ -27,34 +27,6 @@ RSpec.describe API::PackageFiles do expect(response).to have_gitlab_http_status(:not_found) end - - context 'with pipelines' do - let(:package_file_build_info) { create(:package_file_build_info, :with_pipeline, package_file: package.package_files.first) } - - it 'preloads the pipelines' do - expect(::Packages::PackageFile).to receive(:preload_pipelines).and_call_original - - get api(url) - - expect(response).to have_gitlab_http_status(:ok) - end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - end - - it 'does not preload the pipelines' do - expect(::Packages::PackageFile).not_to receive(:preload_pipelines) - - ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/342921') do - get api(url) - end - - expect(response).to have_gitlab_http_status(:ok) - end - end - end end context 'project is private' do diff --git a/spec/services/clusters/cleanup/project_namespace_service_spec.rb b/spec/services/clusters/cleanup/project_namespace_service_spec.rb index 605aaea17e4..ec510b2e3c5 100644 --- a/spec/services/clusters/cleanup/project_namespace_service_spec.rb +++ b/spec/services/clusters/cleanup/project_namespace_service_spec.rb @@ -58,6 +58,19 @@ RSpec.describe Clusters::Cleanup::ProjectNamespaceService do subject end + + context 'when cluster.kubeclient is nil' do + let(:kubeclient_instance_double) { nil } + + it 'schedules ::ServiceAccountWorker' do + expect(Clusters::Cleanup::ServiceAccountWorker).to receive(:perform_async).with(cluster.id) + subject + end + + it 'deletes namespaces from database' do + expect { subject }.to change { cluster.kubernetes_namespaces.exists? }.from(true).to(false) + end + end end context 'when cluster has no namespaces' do diff --git a/spec/services/clusters/cleanup/service_account_service_spec.rb b/spec/services/clusters/cleanup/service_account_service_spec.rb index f256df1b2fc..adcdbd84da0 100644 --- a/spec/services/clusters/cleanup/service_account_service_spec.rb +++ b/spec/services/clusters/cleanup/service_account_service_spec.rb @@ -44,5 +44,13 @@ RSpec.describe Clusters::Cleanup::ServiceAccountService do it 'deletes cluster' do expect { subject }.to change { Clusters::Cluster.where(id: cluster.id).exists? }.from(true).to(false) end + + context 'when cluster.kubeclient is nil' do + let(:kubeclient_instance_double) { nil } + + it 'deletes cluster' do + expect { subject }.to change { Clusters::Cluster.where(id: cluster.id).exists? }.from(true).to(false) + end + end end end diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index ae5687c1e2d..acbc15f7b62 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -53,7 +53,7 @@ module TestEnv 'wip' => 'b9238ee', 'csv' => '3dd0896', 'v1.1.0' => 'b83d6e3', - 'add-ipython-files' => 'c10c411', + 'add-ipython-files' => '2b5ef814', 'add-pdf-file' => 'e774ebd', 'squash-large-files' => '54cec52', 'add-pdf-text-binary' => '79faa7b', diff --git a/spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb b/spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb index 2faeb1a534b..d576a5874fd 100644 --- a/spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb @@ -13,25 +13,6 @@ RSpec.shared_examples 'a package detail' do it_behaves_like 'a working graphql query' do it_behaves_like 'matching the package details schema' end - - context 'with packages_remove_cross_joins_to_pipelines disabled' do - # subject is called in a before callback that is executed before the one below - # the callback below MUST be executed before the subject - # solution: nullify subject and manually call #post_graphql - subject {} - - before do - stub_feature_flags(packages_remove_cross_joins_to_pipelines: false) - - ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/342921') do - post_graphql(query, current_user: user) - end - end - - it_behaves_like 'a working graphql query' do - it_behaves_like 'matching the package details schema' - end - end end end |