Commit 05c38cf9 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'switch_to_real_filepath_allowlist' into 'master'

Switch to the actual spec filepath for spec allowlist

See merge request gitlab-org/gitlab!72584
parents 4ce6e16a ca6c6d8d
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
- "./spec/controllers/groups/settings/ci_cd_controller_spec.rb" - "./spec/controllers/groups/settings/ci_cd_controller_spec.rb"
- "./spec/controllers/projects/settings/ci_cd_controller_spec.rb" - "./spec/controllers/projects/settings/ci_cd_controller_spec.rb"
- "./spec/features/admin/admin_runners_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/ide/user_opens_merge_request_spec.rb"
- "./spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb" - "./spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb"
- "./spec/features/projects/infrastructure_registry_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/pipelines_for_merge_request_finder_spec.rb"
- "./spec/finders/ci/runners_finder_spec.rb" - "./spec/finders/ci/runners_finder_spec.rb"
- "./spec/frontend/fixtures/runner.rb" - "./spec/frontend/fixtures/runner.rb"
...@@ -38,6 +40,7 @@ ...@@ -38,6 +40,7 @@
- "./spec/presenters/packages/detail/package_presenter_spec.rb" - "./spec/presenters/packages/detail/package_presenter_spec.rb"
- "./spec/requests/api/ci/runner/runners_post_spec.rb" - "./spec/requests/api/ci/runner/runners_post_spec.rb"
- "./spec/requests/api/graphql/ci/runner_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/group_query_spec.rb"
- "./spec/requests/api/graphql/packages/composer_spec.rb" - "./spec/requests/api/graphql/packages/composer_spec.rb"
- "./spec/requests/api/graphql/packages/conan_spec.rb" - "./spec/requests/api/graphql/packages/conan_spec.rb"
...@@ -45,12 +48,10 @@ ...@@ -45,12 +48,10 @@
- "./spec/requests/api/graphql/packages/nuget_spec.rb" - "./spec/requests/api/graphql/packages/nuget_spec.rb"
- "./spec/requests/api/graphql/packages/package_spec.rb" - "./spec/requests/api/graphql/packages/package_spec.rb"
- "./spec/requests/api/graphql/packages/pypi_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/requests/api/package_files_spec.rb"
- "./spec/services/environments/stop_service_spec.rb" - "./spec/services/environments/stop_service_spec.rb"
- "./spec/services/merge_requests/post_merge_service_spec.rb" - "./spec/services/merge_requests/post_merge_service_spec.rb"
- "./spec/support/shared_examples/features/packages_shared_examples.rb" - "./spec/services/packages/conan/create_package_file_service_spec.rb"
- "./spec/support/shared_examples/models/concerns/limitable_shared_examples.rb" - "./spec/services/packages/create_package_file_service_spec.rb"
- "./spec/support/shared_examples/requests/api/graphql/packages/group_and_project_packages_list_shared_examples.rb" - "./spec/services/packages/generic/create_package_file_service_spec.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"
...@@ -90,13 +90,23 @@ ActiveRecord::Relation.prepend( ...@@ -90,13 +90,23 @@ ActiveRecord::Relation.prepend(
ALLOW_LIST = Set.new(YAML.load_file(File.join(__dir__, 'cross-join-allowlist.yml'))).freeze 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| RSpec.configure do |config|
config.include(::Database::PreventCrossJoins::SpecHelpers) config.include(::Database::PreventCrossJoins::SpecHelpers)
config.around do |example| config.around do |example|
Thread.current[:has_cross_join_exception] = false 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 example.run
else else
with_cross_joins_prevented { example.run } with_cross_joins_prevented { example.run }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment