diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 03:13:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 03:13:10 +0300 |
commit | a0ef617f9ae96b0ed3fe0054bbbb65d2b80e2b10 (patch) | |
tree | a78e85fdb22233c22035d7434ba69ae6d995e6a7 /spec/support/database | |
parent | 840c85c174e4f134bdce103b8226d5a2a7bcd4ac (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/database')
-rw-r--r-- | spec/support/database/cross-join-allowlist.yml | 13 | ||||
-rw-r--r-- | spec/support/database/prevent_cross_joins.rb | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/spec/support/database/cross-join-allowlist.yml b/spec/support/database/cross-join-allowlist.yml index 86b2ba9333c..12eb8f837f1 100644 --- a/spec/support/database/cross-join-allowlist.yml +++ b/spec/support/database/cross-join-allowlist.yml @@ -16,9 +16,11 @@ - "./spec/controllers/groups/settings/ci_cd_controller_spec.rb" - "./spec/controllers/projects/settings/ci_cd_controller_spec.rb" - "./spec/features/admin/admin_runners_spec.rb" +- "./spec/features/groups/packages_spec.rb" - "./spec/features/ide/user_opens_merge_request_spec.rb" - "./spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb" - "./spec/features/projects/infrastructure_registry_spec.rb" +- "./spec/features/projects/packages_spec.rb" - "./spec/finders/ci/pipelines_for_merge_request_finder_spec.rb" - "./spec/finders/ci/runners_finder_spec.rb" - "./spec/frontend/fixtures/runner.rb" @@ -38,6 +40,7 @@ - "./spec/presenters/packages/detail/package_presenter_spec.rb" - "./spec/requests/api/ci/runner/runners_post_spec.rb" - "./spec/requests/api/graphql/ci/runner_spec.rb" +- "./spec/requests/api/graphql/group/packages_spec.rb" - "./spec/requests/api/graphql/group_query_spec.rb" - "./spec/requests/api/graphql/packages/composer_spec.rb" - "./spec/requests/api/graphql/packages/conan_spec.rb" @@ -45,12 +48,10 @@ - "./spec/requests/api/graphql/packages/nuget_spec.rb" - "./spec/requests/api/graphql/packages/package_spec.rb" - "./spec/requests/api/graphql/packages/pypi_spec.rb" +- "./spec/requests/api/graphql/project/packages_spec.rb" - "./spec/requests/api/package_files_spec.rb" - "./spec/services/environments/stop_service_spec.rb" - "./spec/services/merge_requests/post_merge_service_spec.rb" -- "./spec/support/shared_examples/features/packages_shared_examples.rb" -- "./spec/support/shared_examples/models/concerns/limitable_shared_examples.rb" -- "./spec/support/shared_examples/requests/api/graphql/packages/group_and_project_packages_list_shared_examples.rb" -- "./spec/support/shared_examples/requests/api/graphql/packages/package_details_shared_examples.rb" -- "./spec/support/shared_examples/requests/graphql_shared_examples.rb" -- "./spec/support/shared_examples/services/packages_shared_examples.rb" +- "./spec/services/packages/conan/create_package_file_service_spec.rb" +- "./spec/services/packages/create_package_file_service_spec.rb" +- "./spec/services/packages/generic/create_package_file_service_spec.rb" diff --git a/spec/support/database/prevent_cross_joins.rb b/spec/support/database/prevent_cross_joins.rb index f5ed2a8f22e..94d4e934797 100644 --- a/spec/support/database/prevent_cross_joins.rb +++ b/spec/support/database/prevent_cross_joins.rb @@ -90,13 +90,23 @@ ActiveRecord::Relation.prepend( ALLOW_LIST = Set.new(YAML.load_file(File.join(__dir__, 'cross-join-allowlist.yml'))).freeze +# Based on https://github.com/rspec/rspec-core/blob/d57c371ee92b16211b80ac7b0b025968438f5297/lib/rspec/core/example.rb#L96-L104, +# but with file_path +def example_relative_file_path(example) + loaded_spec_files = RSpec.configuration.loaded_spec_files + + RSpec::Core::Metadata.ascending(example.metadata) do |meta| + break meta[:file_path] if loaded_spec_files.include?(meta[:absolute_file_path]) + end +end + RSpec.configure do |config| config.include(::Database::PreventCrossJoins::SpecHelpers) config.around do |example| Thread.current[:has_cross_join_exception] = false - if ALLOW_LIST.include?(example.file_path) + if ALLOW_LIST.include?(example_relative_file_path(example)) example.run else with_cross_joins_prevented { example.run } |