BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d934d650
Commit
d934d650
authored
Nov 06, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the ignore_column concern to support multiple columns
This method is an ActiveRecord extension and it should behave like one. I expected this to work.
parent
5ab3ed7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
ignorable_column.rb
app/models/concerns/ignorable_column.rb
+2
-2
ignorable_column_spec.rb
spec/models/concerns/ignorable_column_spec.rb
+8
-4
No files found.
app/models/concerns/ignorable_column.rb
View file @
d934d650
...
...
@@ -21,8 +21,8 @@ module IgnorableColumn
@ignored_columns
||=
Set
.
new
end
def
ignore_column
(
name
)
ignored_columns
<<
name
.
to_s
def
ignore_column
(
*
names
)
ignored_columns
.
merge
(
names
.
map
(
&
:to_s
))
end
end
end
spec/models/concerns/ignorable_column_spec.rb
View file @
d934d650
...
...
@@ -5,7 +5,11 @@ describe IgnorableColumn do
Class
.
new
do
def
self
.
columns
# This method does not have access to "double"
[
Struct
.
new
(
:name
).
new
(
'id'
),
Struct
.
new
(
:name
).
new
(
'title'
)]
[
Struct
.
new
(
:name
).
new
(
'id'
),
Struct
.
new
(
:name
).
new
(
'title'
),
Struct
.
new
(
:name
).
new
(
'date'
)
]
end
end
end
...
...
@@ -18,7 +22,7 @@ describe IgnorableColumn do
describe
'.columns'
do
it
'returns the columns, excluding the ignored ones'
do
model
.
ignore_column
(
:title
)
model
.
ignore_column
(
:title
,
:date
)
expect
(
model
.
columns
.
map
(
&
:name
)).
to
eq
(
%w(id)
)
end
...
...
@@ -30,9 +34,9 @@ describe IgnorableColumn do
end
it
'returns the names of the ignored columns'
do
model
.
ignore_column
(
:title
)
model
.
ignore_column
(
:title
,
:date
)
expect
(
model
.
ignored_columns
).
to
eq
(
Set
.
new
(
%w(title)
))
expect
(
model
.
ignored_columns
).
to
eq
(
Set
.
new
(
%w(title
date
)
))
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