Commit ca6c6d8d authored by Thong Kuah's avatar Thong Kuah

Switch to the actual spec filepath for spec allowlist

Instead of using the filepath where the example is defined, use the
filepath where the spec is actually running in.

Updates the spec allowlist yml to use real filepath as well
parent a03f6bef
......@@ -17,9 +17,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"
......@@ -40,6 +42,7 @@
- "./spec/requests/api/ci/runner/runners_post_spec.rb"
- "./spec/requests/api/ci/runners_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"
......@@ -47,12 +50,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"
......@@ -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 }
......
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