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
4d334f76
Commit
4d334f76
authored
Sep 06, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issuable#labels_hash works with with_label([]) to fix CSV export
parent
f60f6872
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+4
-1
changelogs/unreleased-ee/jej-fix-csv-export-filter-by-multiple-labels.yml
...eased-ee/jej-fix-csv-export-filter-by-multiple-labels.yml
+5
-0
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+10
-3
No files found.
app/models/concerns/issuable.rb
View file @
4d334f76
...
...
@@ -205,9 +205,12 @@ module Issuable
def
labels_hash
issue_labels
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
eager_load
(
:labels
).
pluck
(
:id
,
'labels.title'
).
each
do
|
issue_id
,
label
|
relation
=
unscoped
.
where
(
id:
self
.
select
(
:id
)).
eager_load
(
:labels
)
relation
.
pluck
(
:id
,
'labels.title'
).
each
do
|
issue_id
,
label
|
issue_labels
[
issue_id
]
<<
label
end
issue_labels
end
...
...
changelogs/unreleased-ee/jej-fix-csv-export-filter-by-multiple-labels.yml
0 → 100644
View file @
4d334f76
---
title
:
Fix CSV export when filtering issues by multiple labels
merge_request
:
2852
author
:
type
:
fixed
spec/models/concerns/issuable_spec.rb
View file @
4d334f76
...
...
@@ -328,11 +328,18 @@ describe Issuable do
describe
'.labels_hash'
do
let
(
:feature_label
)
{
create
(
:label
,
title:
'Feature'
)
}
let!
(
:issues
)
{
create_list
(
:labeled_issue
,
3
,
labels:
[
feature_label
])
}
let
(
:second_label
)
{
create
(
:label
,
title:
'Second Label'
)
}
let!
(
:issues
)
{
create_list
(
:labeled_issue
,
3
,
labels:
[
feature_label
,
second_label
])
}
let
(
:issue_id
)
{
issues
.
first
.
id
}
it
'maps issue ids to labels titles'
do
issue_id
=
issues
.
first
.
id
expect
(
Issue
.
labels_hash
[
issue_id
]).
to
eq
[
'Feature'
]
expect
(
Issue
.
labels_hash
[
issue_id
]).
to
include
(
'Feature'
)
end
it
'works on relations filtered by multiple labels'
do
relation
=
Issue
.
with_label
([
'Feature'
,
'Second Label'
])
expect
(
relation
.
labels_hash
[
issue_id
]).
to
include
(
'Feature'
,
'Second Label'
)
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