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
761a8599
Commit
761a8599
authored
Nov 18, 2019
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store removal information
parent
b3fd1440
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
app/models/concerns/ignorable_columns.rb
app/models/concerns/ignorable_columns.rb
+10
-0
spec/models/concerns/ignorable_columns_spec.rb
spec/models/concerns/ignorable_columns_spec.rb
+19
-1
No files found.
app/models/concerns/ignorable_columns.rb
View file @
761a8599
...
...
@@ -11,8 +11,18 @@ module IgnorableColumns
raise
ArgumentError
,
'Please indicate when we can stop ignoring columns with remove_after, example: ignore_columns(:name, remove_after: \'2019-12-01\', remove_with: \'12.6\')'
unless
remove_after
&&
remove_with
self
.
ignored_columns
+=
columns
.
flatten
@ignored_columns_details
||=
{}
columns
.
flatten
.
each
do
|
column
|
@ignored_columns_details
[
column
]
=
{
remove_after:
remove_after
,
remove_with:
remove_with
}
end
end
alias_method
:ignore_column
,
:ignore_columns
def
ignored_columns_details
@ignored_columns_details
||
{}
end
end
end
spec/models/concerns/ignorable_columns_spec.rb
View file @
761a8599
...
...
@@ -31,4 +31,22 @@ describe IgnorableColumns do
expect
{
subject
.
ignore_columns
(
:name
,
remove_after:
'2019-12-01'
,
remove_with:
nil
)
}.
to
raise_error
(
ArgumentError
,
/Please indicate/
)
end
describe
'.ignored_columns_details'
do
it
'stores removal information'
do
subject
.
ignore_column
(
:name
,
remove_after:
'2019-12-01'
,
remove_with:
'12.6'
)
expect
(
subject
.
ignored_columns_details
[
:name
]).
to
eq
(
remove_after:
'2019-12-01'
,
remove_with:
'12.6'
)
end
it
'stores removal information (array version)'
do
subject
.
ignore_column
(
%i[name created_at]
,
remove_after:
'2019-12-01'
,
remove_with:
'12.6'
)
expect
(
subject
.
ignored_columns_details
[
:name
]).
to
eq
(
remove_after:
'2019-12-01'
,
remove_with:
'12.6'
)
expect
(
subject
.
ignored_columns_details
[
:created_at
]).
to
eq
(
remove_after:
'2019-12-01'
,
remove_with:
'12.6'
)
end
it
'defaults to empty Hash'
do
expect
(
subject
.
ignored_columns_details
).
to
eq
({})
end
end
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