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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
ee26c3ca
Commit
ee26c3ca
authored
Jun 07, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix label order by priority on labels page
parent
a04897b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
3 deletions
+63
-3
app/models/label.rb
app/models/label.rb
+2
-2
spec/controllers/projects/labels_controller_spec.rb
spec/controllers/projects/labels_controller_spec.rb
+53
-0
spec/features/projects/labels/update_prioritization_spec.rb
spec/features/projects/labels/update_prioritization_spec.rb
+8
-1
No files found.
app/models/label.rb
View file @
ee26c3ca
...
...
@@ -33,11 +33,11 @@ class Label < ActiveRecord::Base
scope
:templates
,
->
{
where
(
template:
true
)
}
def
self
.
prioritized
where
.
not
(
priority:
nil
).
reorder
(
:title
)
where
.
not
(
priority:
nil
).
reorder
(
:
priority
,
:
title
)
end
def
self
.
unprioritized
where
(
priority:
nil
)
.
reorder
(
:title
)
where
(
priority:
nil
)
end
alias_attribute
:name
,
:title
...
...
spec/controllers/projects/labels_controller_spec.rb
0 → 100644
View file @
ee26c3ca
require
'spec_helper'
describe
Projects
::
LabelsController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
sign_in
(
user
)
end
describe
'GET #index'
do
def
create_label
(
attributes
)
create
(
:label
,
attributes
.
merge
(
project:
project
))
end
before
do
15
.
times
{
|
i
|
create_label
(
priority:
(
i
%
3
)
+
1
,
title:
"label
#{
15
-
i
}
"
)
}
5
.
times
{
|
i
|
create_label
(
title:
"label
#{
100
-
i
}
"
)
}
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
end
context
'@prioritized_labels'
do
let
(
:prioritized_labels
)
{
assigns
(
:prioritized_labels
)
}
it
'contains only prioritized labels'
do
expect
(
prioritized_labels
).
to
all
(
have_attributes
(
priority:
a_value
>
0
))
end
it
'is sorted by priority, then label title'
do
priorities_and_titles
=
prioritized_labels
.
pluck
(
:priority
,
:title
)
expect
(
priorities_and_titles
.
sort
).
to
eq
(
priorities_and_titles
)
end
end
context
'@labels'
do
let
(
:labels
)
{
assigns
(
:labels
)
}
it
'contains only unprioritized labels'
do
expect
(
labels
).
to
all
(
have_attributes
(
priority:
nil
))
end
it
'is sorted by label title'
do
titles
=
labels
.
pluck
(
:title
)
expect
(
titles
.
sort
).
to
eq
(
titles
)
end
end
end
end
spec/features/projects/labels/update_prioritization_spec.rb
View file @
ee26c3ca
...
...
@@ -55,7 +55,7 @@ feature 'Prioritize labels', feature: true do
end
end
scenario
'user can sort prioritized labels'
,
js:
true
do
scenario
'user can sort prioritized labels
and persist across reloads
'
,
js:
true
do
bug
=
create
(
:label
,
title:
'bug'
,
priority:
1
)
wontfix
=
create
(
:label
,
title:
'wontfix'
,
priority:
2
)
...
...
@@ -75,6 +75,13 @@ feature 'Prioritize labels', feature: true do
expect
(
first
(
'li'
)).
to
have_content
(
'wontfix'
)
expect
(
page
.
all
(
'li'
).
last
).
to
have_content
(
'bug'
)
end
visit
current_url
page
.
within
(
'.prioritized-labels'
)
do
expect
(
first
(
'li'
)).
to
have_content
(
'wontfix'
)
expect
(
page
.
all
(
'li'
).
last
).
to
have_content
(
'bug'
)
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