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
7a0efe30
Commit
7a0efe30
authored
Jul 07, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dashboard labels dropdown
parent
d0d27531
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
4 deletions
+39
-4
app/controllers/dashboard/labels_controller.rb
app/controllers/dashboard/labels_controller.rb
+7
-2
app/models/global_label.rb
app/models/global_label.rb
+1
-1
app/serializers/label_entity.rb
app/serializers/label_entity.rb
+2
-1
changelogs/unreleased/34590-fix-dashboard-labels-dropdown.yml
...gelogs/unreleased/34590-fix-dashboard-labels-dropdown.yml
+4
-0
spec/controllers/dashboard/labels_controller_spec.rb
spec/controllers/dashboard/labels_controller_spec.rb
+25
-0
No files found.
app/controllers/dashboard/labels_controller.rb
View file @
7a0efe30
class
Dashboard::LabelsController
<
Dashboard
::
ApplicationController
def
index
labels
=
LabelsFinder
.
new
(
current_user
).
execute
respond_to
do
|
format
|
format
.
json
{
render
json:
LabelSerializer
.
new
.
represent_appearance
(
labels
)
}
end
end
def
labels
finder_params
=
{
project_ids:
projects
.
select
(
:id
)
}
labels
=
LabelsFinder
.
new
(
current_user
,
finder_params
).
execute
GlobalLabel
.
build_collection
(
labels
)
end
end
app/models/global_label.rb
View file @
7a0efe30
...
...
@@ -2,7 +2,7 @@ class GlobalLabel
attr_accessor
:title
,
:labels
alias_attribute
:name
,
:title
delegate
:color
,
:description
,
to: :@first_label
delegate
:color
,
:
text_color
,
:
description
,
to: :@first_label
def
for_display
@first_label
...
...
app/serializers/label_entity.rb
View file @
7a0efe30
class
LabelEntity
<
Grape
::
Entity
expose
:id
expose
:id
,
if:
->
(
label
,
_
)
{
!
label
.
is_a?
(
GlobalLabel
)
}
expose
:title
expose
:color
expose
:description
...
...
changelogs/unreleased/34590-fix-dashboard-labels-dropdown.yml
0 → 100644
View file @
7a0efe30
---
title
:
Fix dashboard labels dropdown
merge_request
:
12708
author
:
spec/controllers/dashboard/labels_controller_spec.rb
0 → 100644
View file @
7a0efe30
require
'spec_helper'
describe
Dashboard
::
LabelsController
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:label
)
{
create
(
:label
,
project:
project
)
}
before
do
sign_in
(
user
)
project
.
add_reporter
(
user
)
end
describe
"#index"
do
let!
(
:unrelated_label
)
{
create
(
:label
,
project:
create
(
:empty_project
,
:public
))
}
it
'returns global labels for projects the user has a relationship with'
do
get
:index
,
format: :json
expect
(
json_response
).
to
be_kind_of
(
Array
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
[
0
][
"id"
]).
to
be_nil
expect
(
json_response
[
0
][
"title"
]).
to
eq
(
label
.
title
)
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