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
179c0824
Commit
179c0824
authored
Jun 27, 2019
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix weight quick action to support 0 value
parent
b6cb3cbb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
7 deletions
+61
-7
ee/changelogs/unreleased/10324-weight-fix.yml
ee/changelogs/unreleased/10324-weight-fix.yml
+5
-0
ee/lib/ee/gitlab/quick_actions/issue_and_merge_request_actions.rb
...e/gitlab/quick_actions/issue_and_merge_request_actions.rb
+1
-1
ee/spec/services/ee/issues/update_service_spec.rb
ee/spec/services/ee/issues/update_service_spec.rb
+31
-0
ee/spec/services/quick_actions/interpret_service_spec.rb
ee/spec/services/quick_actions/interpret_service_spec.rb
+24
-6
No files found.
ee/changelogs/unreleased/10324-weight-fix.yml
0 → 100644
View file @
179c0824
---
title
:
Fix weight quick action to support 0 value
merge_request
:
14432
author
:
type
:
fixed
ee/lib/ee/gitlab/quick_actions/issue_and_merge_request_actions.rb
View file @
179c0824
...
...
@@ -34,7 +34,7 @@ module EE
current_user
.
can?
(
:"admin_
#{
quick_action_target
.
to_ability_name
}
"
,
quick_action_target
)
end
parse_params
do
|
weight
|
weight
.
to_i
if
weight
.
to_i
>
0
weight
.
to_i
if
weight
.
to_i
>
=
0
end
command
:weight
do
|
weight
|
@updates
[
:weight
]
=
weight
if
weight
...
...
ee/spec/services/ee/issues/update_service_spec.rb
View file @
179c0824
...
...
@@ -27,6 +27,37 @@ describe Issues::UpdateService do
end
end
context
'updating weight'
do
before
do
project
.
add_maintainer
(
user
)
issue
.
update
(
weight:
3
)
end
context
'when weight is integer'
do
it
'updates to the exact value'
do
expect
{
update_issue
(
weight:
2
)
}.
to
change
{
issue
.
weight
}.
to
(
2
)
end
end
context
'when weight is integer'
do
it
'rounds the value down'
do
expect
{
update_issue
(
weight:
1.8
)
}.
to
change
{
issue
.
weight
}.
to
(
1
)
end
end
context
'when weight is zero'
do
it
'sets the value to zero'
do
expect
{
update_issue
(
weight:
0
)
}.
to
change
{
issue
.
weight
}.
to
(
0
)
end
end
context
'when weight is a string'
do
it
'sets the value to 0'
do
expect
{
update_issue
(
weight:
'abc'
)
}.
to
change
{
issue
.
weight
}.
to
(
0
)
end
end
end
context
'updating other fields'
do
it
'does not call epic#update_start_and_due_dates'
do
expect
(
epic
).
not_to
receive
(
:update_start_and_due_dates
)
...
...
ee/spec/services/quick_actions/interpret_service_spec.rb
View file @
179c0824
...
...
@@ -682,19 +682,37 @@ describe QuickActions::InterpretService do
end
context
'issuable weights licensed'
do
let
(
:issuable
)
{
issue
}
before
do
stub_licensed_features
(
issue_weights:
true
)
end
it_behaves_like
'weight command'
do
let
(
:weight
)
{
5
}
context
'weight'
do
let
(
:content
)
{
"/weight
#{
weight
}
"
}
let
(
:issuable
)
{
issue
}
it_behaves_like
'weight command'
do
let
(
:weight
)
{
5
}
end
it_behaves_like
'weight command'
do
let
(
:weight
)
{
0
}
end
context
'when weight is negative'
do
it
'does not populate weight'
do
content
=
"/weight -10"
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
be_empty
end
end
end
it_behaves_like
'clear weight command'
do
let
(
:content
)
{
'/clear_weight'
}
let
(
:issuable
)
{
issue
}
context
'clear_weight'
do
it_behaves_like
'clear weight command'
do
let
(
:content
)
{
'/clear_weight'
}
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