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
Jérome Perrin
gitlab-ce
Commits
104c4f88
Commit
104c4f88
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Boards::Issues::MoveService to move issues on a specific board
parent
1fa3f308
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+4
-0
spec/services/boards/issues/move_service_spec.rb
spec/services/boards/issues/move_service_spec.rb
+12
-12
No files found.
app/services/boards/issues/move_service.rb
View file @
104c4f88
...
@@ -10,6 +10,10 @@ module Boards
...
@@ -10,6 +10,10 @@ module Boards
private
private
def
board
@board
||=
project
.
boards
.
find
(
params
[
:board_id
])
end
def
valid_move?
def
valid_move?
moving_from_list
.
present?
&&
moving_to_list
.
present?
&&
moving_from_list
.
present?
&&
moving_to_list
.
present?
&&
moving_from_list
!=
moving_to_list
moving_from_list
!=
moving_to_list
...
...
spec/services/boards/issues/move_service_spec.rb
View file @
104c4f88
...
@@ -3,17 +3,17 @@ require 'spec_helper'
...
@@ -3,17 +3,17 @@ require 'spec_helper'
describe
Boards
::
Issues
::
MoveService
,
services:
true
do
describe
Boards
::
Issues
::
MoveService
,
services:
true
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:
project_with_board
)
}
let
(
:project
)
{
create
(
:
empty_project
)
}
let
(
:board
)
{
project
.
board
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
name:
'Bug'
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
name:
'Bug'
)
}
let
(
:development
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let
(
:development
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let
(
:testing
)
{
create
(
:label
,
project:
project
,
name:
'Testing'
)
}
let
(
:testing
)
{
create
(
:label
,
project:
project
,
name:
'Testing'
)
}
let!
(
:backlog
)
{
project
.
board
.
backlog_list
}
let!
(
:backlog
)
{
create
(
:backlog_list
,
board:
board
)
}
let!
(
:list1
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let!
(
:list1
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:done
)
{
project
.
board
.
done_list
}
let!
(
:done
)
{
create
(
:done_list
,
board:
board
)
}
before
do
before
do
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
...
@@ -22,7 +22,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -22,7 +22,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from backlog'
do
context
'when moving from backlog'
do
it
'adds the label of the list it goes to'
do
it
'adds the label of the list it goes to'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
params
=
{
from_list_id:
backlog
.
id
,
to_list_id:
list1
.
id
}
params
=
{
board_id:
board
.
id
,
from_list_id:
backlog
.
id
,
to_list_id:
list1
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
...
@@ -33,7 +33,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -33,7 +33,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving to backlog'
do
context
'when moving to backlog'
do
it
'removes all list-labels'
do
it
'removes all list-labels'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
params
=
{
from_list_id:
list1
.
id
,
to_list_id:
backlog
.
id
}
params
=
{
board_id:
board
.
id
,
from_list_id:
list1
.
id
,
to_list_id:
backlog
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
...
@@ -44,7 +44,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -44,7 +44,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from backlog to done'
do
context
'when moving from backlog to done'
do
it
'closes the issue'
do
it
'closes the issue'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
params
=
{
from_list_id:
backlog
.
id
,
to_list_id:
done
.
id
}
params
=
{
board_id:
board
.
id
,
from_list_id:
backlog
.
id
,
to_list_id:
done
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
...
@@ -56,7 +56,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -56,7 +56,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving an issue between lists'
do
context
'when moving an issue between lists'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:params
)
{
{
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
}
}
let
(
:params
)
{
{
board_id:
board
.
id
,
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
}
}
it
'delegates the label changes to Issues::UpdateService'
do
it
'delegates the label changes to Issues::UpdateService'
do
expect_any_instance_of
(
Issues
::
UpdateService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
UpdateService
).
to
receive
(
:execute
).
with
(
issue
).
once
...
@@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving to done'
do
context
'when moving to done'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
}
let
(
:params
)
{
{
from_list_id:
list2
.
id
,
to_list_id:
done
.
id
}
}
let
(
:params
)
{
{
board_id:
board
.
id
,
from_list_id:
list2
.
id
,
to_list_id:
done
.
id
}
}
it
'delegates the close proceedings to Issues::CloseService'
do
it
'delegates the close proceedings to Issues::CloseService'
do
expect_any_instance_of
(
Issues
::
CloseService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
CloseService
).
to
receive
(
:execute
).
with
(
issue
).
once
...
@@ -92,7 +92,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -92,7 +92,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from done'
do
context
'when moving from done'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let
(
:params
)
{
{
from_list_id:
done
.
id
,
to_list_id:
list2
.
id
}
}
let
(
:params
)
{
{
board_id:
board
.
id
,
from_list_id:
done
.
id
,
to_list_id:
list2
.
id
}
}
it
'delegates the re-open proceedings to Issues::ReopenService'
do
it
'delegates the re-open proceedings to Issues::ReopenService'
do
expect_any_instance_of
(
Issues
::
ReopenService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
ReopenService
).
to
receive
(
:execute
).
with
(
issue
).
once
...
@@ -112,7 +112,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -112,7 +112,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from done to backlog'
do
context
'when moving from done to backlog'
do
it
'reopens the issue'
do
it
'reopens the issue'
do
issue
=
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
params
=
{
from_list_id:
done
.
id
,
to_list_id:
backlog
.
id
}
params
=
{
board_id:
board
.
id
,
from_list_id:
done
.
id
,
to_list_id:
backlog
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
...
@@ -124,7 +124,7 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -124,7 +124,7 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving to same list'
do
context
'when moving to same list'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:params
)
{
{
from_list_id:
list1
.
id
,
to_list_id:
list1
.
id
}
}
let
(
:params
)
{
{
board_id:
board
.
id
,
from_list_id:
list1
.
id
,
to_list_id:
list1
.
id
}
}
it
'returns false'
do
it
'returns false'
do
expect
(
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)).
to
eq
false
expect
(
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)).
to
eq
false
...
...
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