Skip to content

Fix order-dependent failure in bulk_insert_safe_spec.rb

Stan Hu requested to merge sh-fix-bulk-insert-schema-leakage into master

This would fail if spec/models/concerns/bulk_insert_safe_spec.rb and spec/lib/gitlab/doctor/secrets_spec.rb were run in order.

The test failed because bulk_insert_items is a temporary table inserted by the test and dropped afterwards. However, the test also defines a BulkInsertItem class, which the GitLab Doctor secrets task uses to identify encrypted columns.

To fix this, we change BulkInsertItem to inherit from ActiveRecord::Base instead of ApplicationRecord. We also make sure the first spec resets the model cache after dropping the table for completeness.

Closes #221784 (closed)

Edited by Stan Hu

Merge request reports