summaryrefslogtreecommitdiff
path: root/spec/support/helpers/database
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-07 12:09:35 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-07 12:09:35 +0000
commit2abeca2d92cfe3bc18441b63ca0c54af086b206e (patch)
tree72f02f9c0470b897f31c45a6b7ccce6fe57955b0 /spec/support/helpers/database
parentf4a9d976cf03888fbfd81ab9813720f4e8ec8056 (diff)
downloadgitlab-ce-2abeca2d92cfe3bc18441b63ca0c54af086b206e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/database')
-rw-r--r--spec/support/helpers/database/database_helpers.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/spec/support/helpers/database/database_helpers.rb b/spec/support/helpers/database/database_helpers.rb
index db093bcef85..f3b2a2a6147 100644
--- a/spec/support/helpers/database/database_helpers.rb
+++ b/spec/support/helpers/database/database_helpers.rb
@@ -4,8 +4,10 @@ module Database
module DatabaseHelpers
# In order to directly work with views using factories,
# we can swapout the view for a table of identical structure.
- def swapout_view_for_table(view)
- ActiveRecord::Base.connection.execute(<<~SQL.squish)
+ def swapout_view_for_table(view, connection: nil)
+ connection ||= ActiveRecord::Base.connection
+
+ connection.execute(<<~SQL.squish)
CREATE TABLE #{view}_copy (LIKE #{view});
DROP VIEW #{view};
ALTER TABLE #{view}_copy RENAME TO #{view};