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
29cef6ee
Commit
29cef6ee
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Boards::CreateService to allow projects to have many boards
parent
1df2be43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
+35
-22
app/services/boards/create_service.rb
app/services/boards/create_service.rb
+5
-12
spec/services/boards/create_service_spec.rb
spec/services/boards/create_service_spec.rb
+30
-10
No files found.
app/services/boards/create_service.rb
View file @
29cef6ee
module
Boards
class
CreateService
<
BaseService
def
execute
if
project
.
boards
.
empty?
create_board!
else
project
.
boards
.
first
end
end
board
=
project
.
boards
.
create
(
params
)
private
def
create_board!
board
=
project
.
boards
.
create
board
.
lists
.
create
(
list_type: :backlog
)
board
.
lists
.
create
(
list_type: :done
)
if
board
.
persisted?
board
.
lists
.
create
(
list_type: :backlog
)
board
.
lists
.
create
(
list_type: :done
)
end
board
end
...
...
spec/services/boards/create_service_spec.rb
View file @
29cef6ee
...
...
@@ -4,14 +4,14 @@ describe Boards::CreateService, services: true do
describe
'#execute'
do
let
(
:project
)
{
create
(
:empty_project
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
double
)
}
context
'with valid params'
do
subject
(
:service
)
{
described_class
.
new
(
project
,
double
,
name:
'Backend'
)
}
context
'when project does not have a board'
do
it
'creates a new board'
do
expect
{
service
.
execute
}.
to
change
(
Board
,
:count
).
by
(
1
)
it
'creates a new project board'
do
expect
{
service
.
execute
}.
to
change
(
project
.
boards
,
:count
).
by
(
1
)
end
it
'creates default lists'
do
it
"creates board's default lists"
do
board
=
service
.
execute
expect
(
board
.
lists
.
size
).
to
eq
2
...
...
@@ -20,14 +20,34 @@ describe Boards::CreateService, services: true do
end
end
context
'when project has a board'
do
before
do
create
(
:board
,
project:
project
)
end
context
'with invalid params'
do
subject
(
:service
)
{
described_class
.
new
(
project
,
double
,
name:
nil
)
}
it
'does not create a new board'
do
it
'does not create a new
project
board'
do
expect
{
service
.
execute
}.
not_to
change
(
project
.
boards
,
:count
)
end
it
"does not create board's default lists"
do
board
=
service
.
execute
expect
(
board
.
lists
.
size
).
to
eq
0
end
end
context
'without params'
do
subject
(
:service
)
{
described_class
.
new
(
project
,
double
)
}
it
'creates a new project board'
do
expect
{
service
.
execute
}.
to
change
(
project
.
boards
,
:count
).
by
(
1
)
end
it
"creates board's default lists"
do
board
=
service
.
execute
expect
(
board
.
lists
.
size
).
to
eq
2
expect
(
board
.
lists
.
first
).
to
be_backlog
expect
(
board
.
lists
.
last
).
to
be_done
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