Commit c57061c4 authored by Stan Hu's avatar Stan Hu

Fix order-dependent failure in bulk_insert_safe_spec.rb

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 https://gitlab.com/gitlab-org/gitlab/-/issues/221784
parent f64eaae4
......@@ -3,7 +3,7 @@
require 'spec_helper'
describe BulkInsertSafe do
class BulkInsertItem < ApplicationRecord
class BulkInsertItem < ActiveRecord::Base
include BulkInsertSafe
include ShaAttribute
......@@ -74,6 +74,8 @@ describe BulkInsertSafe do
ActiveRecord::Schema.define do
drop_table :bulk_insert_items, force: true
end
BulkInsertItem.reset_column_information
end
describe BulkInsertItem do
......
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