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
4180a15c
Commit
4180a15c
authored
Jul 28, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Backlog/Done lists when creating a new board
parent
b23683b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
13 deletions
+32
-13
app/services/boards/create_service.rb
app/services/boards/create_service.rb
+8
-5
spec/services/boards/create_service_spec.rb
spec/services/boards/create_service_spec.rb
+24
-8
No files found.
app/services/boards/create_service.rb
View file @
4180a15c
...
...
@@ -5,15 +5,18 @@ module Boards
end
def
execute
if
project
.
board
.
present?
project
.
board
else
project
.
create_board
end
create_board!
unless
project
.
board
.
present?
project
.
board
end
private
attr_reader
:project
def
create_board!
project
.
create_board
project
.
board
.
lists
.
create
(
list_type: :backlog
,
position:
0
)
project
.
board
.
lists
.
create
(
list_type: :done
,
position:
1
)
end
end
end
spec/services/boards/create_service_spec.rb
View file @
4180a15c
...
...
@@ -2,18 +2,34 @@ require 'spec_helper'
describe
Boards
::
CreateService
,
services:
true
do
describe
'#execute'
do
it
'creates a new board when project does not has one'
do
project
=
create
(
:empty_project
,
board:
nil
)
service
=
described_class
.
new
(
project
)
subject
(
:service
)
{
described_class
.
new
(
project
)
}
expect
{
service
.
execute
}.
to
change
(
Board
,
:count
).
by
(
1
)
context
'when project does not have a board'
do
let
(
:project
)
{
create
(
:empty_project
,
board:
nil
)
}
it
'creates a new board'
do
expect
{
service
.
execute
}.
to
change
(
Board
,
:count
).
by
(
1
)
end
it
'creates default lists'
do
service
.
execute
expect
(
project
.
board
.
lists
.
size
).
to
eq
2
expect
(
project
.
board
.
lists
.
first
).
to
be_backlog
expect
(
project
.
board
.
lists
.
last
).
to
be_done
end
end
it
'returns project board when project has one'
do
project
=
create
(
:project_with_board
)
service
=
described_class
.
new
(
project
)
context
'when project has a board'
do
let!
(
:project
)
{
create
(
:project_with_board
)
}
it
'does not create a new board'
do
expect
{
service
.
execute
}.
not_to
change
(
Board
,
:count
)
end
expect
(
service
.
execute
).
to
eq
project
.
board
it
'does not create board lists'
do
expect
{
service
.
execute
}.
not_to
change
(
project
.
board
.
lists
,
:count
)
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