diff options
Diffstat (limited to 'spec/support/shared_examples/models/concerns')
-rw-r--r-- | spec/support/shared_examples/models/concerns/bulk_insert_safe_shared_examples.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/support/shared_examples/models/concerns/bulk_insert_safe_shared_examples.rb b/spec/support/shared_examples/models/concerns/bulk_insert_safe_shared_examples.rb index 0a2b6616bb4..78d0945ea63 100644 --- a/spec/support/shared_examples/models/concerns/bulk_insert_safe_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/bulk_insert_safe_shared_examples.rb @@ -1,6 +1,11 @@ # frozen_string_literal: true -RSpec.shared_examples 'a BulkInsertSafe model' do |target_class| +RSpec.shared_examples 'a BulkInsertSafe model' do |klass| + # Call `.dup` on the class passed in, as a test in this set of examples + # calls `belongs_to` on the class, thereby adding a new belongs_to + # relationship to the model that can break remaining specs in the test suite. + let(:target_class) { klass.dup } + # We consider all callbacks unsafe for bulk insertions unless we have explicitly # whitelisted them (esp. anything related to :save, :create, :commit etc.) let(:callback_method_blacklist) do |