Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
88b50ab3
Commit
88b50ab3
authored
Feb 22, 2021
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `stub_const` to avoid disabling cop RSpec/LeakyConstantDeclaration
parent
a32daf12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
spec/lib/gitlab/database/bulk_update_spec.rb
spec/lib/gitlab/database/bulk_update_spec.rb
+7
-11
No files found.
spec/lib/gitlab/database/bulk_update_spec.rb
View file @
88b50ab3
...
...
@@ -113,23 +113,19 @@ RSpec.describe Gitlab::Database::BulkUpdate do
include_examples
'basic functionality'
context
'when prepared statements are configured differently to the normal test environment'
do
# rubocop: disable RSpec/LeakyConstantDeclaration
# This cop is disabled because you cannot call establish_connection on
# an anonymous class.
class
ActiveRecordBasePreparedStatementsInverted
<
ActiveRecord
::
Base
def
self
.
abstract_class?
true
# So it gets its own connection
before
do
klass
=
Class
.
new
(
ActiveRecord
::
Base
)
do
def
self
.
abstract_class?
true
# So it gets its own connection
end
end
end
# rubocop: enable RSpec/LeakyConstantDeclaration
before_all
do
stub_const
(
'ActiveRecordBasePreparedStatementsInverted'
,
klass
)
c
=
ActiveRecord
::
Base
.
connection
.
instance_variable_get
(
:@config
)
inverted
=
c
.
merge
(
prepared_statements:
!
ActiveRecord
::
Base
.
connection
.
prepared_statements
)
ActiveRecordBasePreparedStatementsInverted
.
establish_connection
(
inverted
)
end
before
do
allow
(
ActiveRecord
::
Base
).
to
receive
(
:connection_specification_name
)
.
and_return
(
ActiveRecordBasePreparedStatementsInverted
.
connection_specification_name
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment