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
19f942a9
Commit
19f942a9
authored
May 21, 2020
by
Rajendra Kadam
Committed by
Peter Leitzen
May 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leaky constant in migration helpers and ignored cols spec
parent
11271ac4
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
86 deletions
+105
-86
.rubocop.yml
.rubocop.yml
+0
-3
changelogs/unreleased/leaky-constant-fix-37.yml
changelogs/unreleased/leaky-constant-fix-37.yml
+5
-0
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+66
-57
spec/lib/gitlab/database/obsolete_ignored_columns_spec.rb
spec/lib/gitlab/database/obsolete_ignored_columns_spec.rb
+32
-23
spec/lib/gitlab/database/with_lock_retries_spec.rb
spec/lib/gitlab/database/with_lock_retries_spec.rb
+2
-3
No files found.
.rubocop.yml
View file @
19f942a9
...
...
@@ -351,9 +351,6 @@ RSpec/LeakyConstantDeclaration:
-
'
spec/db/schema_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/lib/gitlab/config/entry/simplifiable_spec.rb'
-
'
spec/lib/gitlab/database/migration_helpers_spec.rb'
-
'
spec/lib/gitlab/database/obsolete_ignored_columns_spec.rb'
-
'
spec/lib/gitlab/database/with_lock_retries_spec.rb'
-
'
spec/lib/gitlab/git/diff_collection_spec.rb'
-
'
spec/lib/gitlab/import_export/import_test_coverage_spec.rb'
-
'
spec/lib/gitlab/import_export/project/relation_factory_spec.rb'
...
...
changelogs/unreleased/leaky-constant-fix-37.yml
0 → 100644
View file @
19f942a9
---
title
:
Fix leaky constant issue in migration helpers, with lock retries and ignored cols spec
merge_request
:
32170
author
:
Rajendra Kadam
type
:
fixed
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
19f942a9
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/database/obsolete_ignored_columns_spec.rb
View file @
19f942a9
...
...
@@ -3,14 +3,22 @@
require
'spec_helper'
describe
Gitlab
::
Database
::
ObsoleteIgnoredColumns
do
module
Testing
before
do
stub_const
(
'Testing'
,
Module
.
new
)
stub_const
(
'Testing::MyBase'
,
Class
.
new
(
ActiveRecord
::
Base
))
stub_const
(
'SomeAbstract'
,
Class
.
new
(
Testing
::
MyBase
))
stub_const
(
'Testing::B'
,
Class
.
new
(
Testing
::
MyBase
))
stub_const
(
'Testing::A'
,
Class
.
new
(
SomeAbstract
))
stub_const
(
'Testing::C'
,
Class
.
new
(
Testing
::
MyBase
))
# Used a fixed date to prevent tests failing across date boundaries
REMOVE_DATE
=
Date
.
new
(
2019
,
12
,
16
)
stub_const
(
'REMOVE_DATE'
,
Date
.
new
(
2019
,
12
,
16
)
)
class
MyBase
<
ApplicationRecord
Testing
.
module_eval
do
Testing
::
MyBase
.
class_eval
do
end
class
SomeAbstract
<
MyBase
SomeAbstract
.
class_eval
do
include
IgnorableColumns
self
.
abstract_class
=
true
...
...
@@ -20,7 +28,7 @@ describe Gitlab::Database::ObsoleteIgnoredColumns do
ignore_column
:unused
,
remove_after:
'2019-01-01'
,
remove_with:
'12.0'
end
class
B
<
MyBase
Testing
::
B
.
class_eval
do
include
IgnorableColumns
self
.
table_name
=
'issues'
...
...
@@ -29,21 +37,22 @@ describe Gitlab::Database::ObsoleteIgnoredColumns do
ignore_column
:not_used_but_still_ignored
,
remove_after:
REMOVE_DATE
.
to_s
,
remove_with:
'12.1'
end
class
A
<
SomeAbstract
Testing
::
A
.
class_eval
do
ignore_column
:also_unused
,
remove_after:
'2019-02-01'
,
remove_with:
'12.1'
ignore_column
:not_used_but_still_ignored
,
remove_after:
REMOVE_DATE
.
to_s
,
remove_with:
'12.1'
end
class
C
<
MyBase
Testing
::
C
.
class_eval
do
self
.
table_name
=
'users'
end
end
end
subject
{
described_class
.
new
(
Testing
::
MyBase
)
}
describe
'#execute'
do
it
'returns a list of class names and columns pairs'
do
Timecop
.
freeze
(
Testing
::
REMOVE_DATE
)
do
Timecop
.
freeze
(
REMOVE_DATE
)
do
expect
(
subject
.
execute
).
to
eq
([
[
'Testing::A'
,
{
'unused'
=>
IgnorableColumns
::
ColumnIgnore
.
new
(
Date
.
parse
(
'2019-01-01'
),
'12.0'
),
...
...
spec/lib/gitlab/database/with_lock_retries_spec.rb
View file @
19f942a9
...
...
@@ -35,9 +35,6 @@ describe Gitlab::Database::WithLockRetries do
end
context
'when lock retry is enabled'
do
class
ActiveRecordSecond
<
ActiveRecord
::
Base
end
let
(
:lock_fiber
)
do
Fiber
.
new
do
# Initiating a second DB connection for the lock
...
...
@@ -52,6 +49,8 @@ describe Gitlab::Database::WithLockRetries do
end
before
do
stub_const
(
'ActiveRecordSecond'
,
Class
.
new
(
ActiveRecord
::
Base
))
lock_fiber
.
resume
# start the transaction and lock the table
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