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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
7481fc5a
Commit
7481fc5a
authored
Mar 28, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 404 in group boards when moving issue between lists
parent
160d29b8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
8 deletions
+69
-8
app/assets/javascripts/boards/services/board_service.js
app/assets/javascripts/boards/services/board_service.js
+1
-1
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+4
-1
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+13
-4
changelogs/unreleased/issue_44551.yml
changelogs/unreleased/issue_44551.yml
+5
-0
spec/services/boards/issues/move_service_spec.rb
spec/services/boards/issues/move_service_spec.rb
+1
-1
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+31
-0
spec/support/shared_examples/services/boards/issues_move_service.rb
...rt/shared_examples/services/boards/issues_move_service.rb
+14
-1
No files found.
app/assets/javascripts/boards/services/board_service.js
View file @
7481fc5a
...
...
@@ -19,7 +19,7 @@ export default class BoardService {
}
static
generateIssuePath
(
boardId
,
id
)
{
return
`
${
gon
.
relative_url_root
}
/-/boards/
${
boardId
?
`
/
${
boardId
}
`
:
''
}
/issues
${
id
?
`/
${
id
}
`
:
''
}
`
;
return
`
${
gon
.
relative_url_root
}
/-/boards/
${
boardId
?
`
${
boardId
}
`
:
''
}
/issues
${
id
?
`/
${
id
}
`
:
''
}
`
;
}
all
()
{
...
...
app/services/boards/issues/move_service.rb
View file @
7481fc5a
...
...
@@ -42,7 +42,10 @@ module Boards
)
end
attrs
[
:move_between_ids
]
=
move_between_ids
if
move_between_ids
if
move_between_ids
attrs
[
:move_between_ids
]
=
move_between_ids
attrs
[
:board_group_id
]
=
board
.
group
&
.
id
end
attrs
end
...
...
app/services/issues/update_service.rb
View file @
7481fc5a
...
...
@@ -55,9 +55,10 @@ module Issues
return
unless
params
[
:move_between_ids
]
after_id
,
before_id
=
params
.
delete
(
:move_between_ids
)
board_group_id
=
params
.
delete
(
:board_group_id
)
issue_before
=
get_issue_if_allowed
(
issue
.
project
,
before_id
)
if
before_id
issue_after
=
get_issue_if_allowed
(
issue
.
project
,
after_id
)
if
after_id
issue_before
=
get_issue_if_allowed
(
before_id
,
board_group_id
)
issue_after
=
get_issue_if_allowed
(
after_id
,
board_group_id
)
issue
.
move_between
(
issue_before
,
issue_after
)
end
...
...
@@ -84,8 +85,16 @@ module Issues
private
def
get_issue_if_allowed
(
project
,
id
)
issue
=
project
.
issues
.
find
(
id
)
def
get_issue_if_allowed
(
id
,
board_group_id
=
nil
)
return
unless
id
issue
=
if
board_group_id
IssuesFinder
.
new
(
current_user
,
group_id:
board_group_id
).
find_by
(
id:
id
)
else
project
.
issues
.
find
(
id
)
end
issue
if
can?
(
current_user
,
:update_issue
,
issue
)
end
...
...
changelogs/unreleased/issue_44551.yml
0 → 100644
View file @
7481fc5a
---
title
:
Fix 404 in group boards when moving issue between lists
merge_request
:
author
:
type
:
fixed
spec/services/boards/issues/move_service_spec.rb
View file @
7481fc5a
...
...
@@ -48,7 +48,7 @@ describe Boards::Issues::MoveService do
parent
.
add_developer
(
user
)
end
it_behaves_like
'issues move service'
it_behaves_like
'issues move service'
,
true
end
end
end
spec/services/issues/update_service_spec.rb
View file @
7481fc5a
...
...
@@ -97,6 +97,37 @@ describe Issues::UpdateService, :mailer do
expect
(
issue
.
relative_position
).
to
be_between
(
issue1
.
relative_position
,
issue2
.
relative_position
)
end
context
'when moving issue between issues from different projects'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project_1
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:project_2
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:project_3
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:issue_1
)
{
create
(
:issue
,
project:
project_1
)
}
let
(
:issue_2
)
{
create
(
:issue
,
project:
project_2
)
}
let
(
:issue_3
)
{
create
(
:issue
,
project:
project_3
)
}
before
do
group
.
add_developer
(
user
)
end
it
'sorts issues as specified by parameters'
do
# Moving all issues to end here like the last example won't work since
# all projects only have the same issue count
# so their relative_position will be the same.
issue_1
.
move_to_end
issue_2
.
move_after
(
issue_1
)
issue_3
.
move_after
(
issue_2
)
[
issue_1
,
issue_2
,
issue_3
].
map
(
&
:save
)
opts
[
:move_between_ids
]
=
[
issue_1
.
id
,
issue_2
.
id
]
opts
[
:board_group_id
]
=
group
.
id
described_class
.
new
(
issue_3
.
project
,
user
,
opts
).
execute
(
issue_3
)
expect
(
issue_2
.
relative_position
).
to
be_between
(
issue_1
.
relative_position
,
issue_2
.
relative_position
)
end
end
context
'when current user cannot admin issues in the project'
do
let
(
:guest
)
{
create
(
:user
)
}
before
do
...
...
spec/support/shared_examples/services/boards/issues_move_service.rb
View file @
7481fc5a
shared_examples
'issues move service'
do
shared_examples
'issues move service'
do
|
group
|
context
'when moving an issue between lists'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:params
)
{
{
board_id:
board1
.
id
,
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
}
}
...
...
@@ -83,5 +83,18 @@ shared_examples 'issues move service' do
expect
(
issue
.
relative_position
).
to
be_between
(
issue1
.
relative_position
,
issue2
.
relative_position
)
end
if
group
context
'when on a group board'
do
it
'sends the board_group_id parameter'
do
params
.
merge!
(
move_after_id:
issue1
.
id
,
move_before_id:
issue2
.
id
)
match_params
=
{
move_between_ids:
[
issue1
.
id
,
issue2
.
id
],
board_group_id:
parent
.
id
}
expect
(
Issues
::
UpdateService
).
to
receive
(
:new
).
with
(
issue
.
project
,
user
,
match_params
).
and_return
(
double
(
execute:
build
(
:issue
)))
described_class
.
new
(
parent
,
user
,
params
).
execute
(
issue
)
end
end
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