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
Tatuya Kamada
gitlab-ce
Commits
68cfdba7
Commit
68cfdba7
authored
Aug 08, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add service to generate default board lists
parent
e23d1706
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
app/services/boards/lists/generate_service.rb
app/services/boards/lists/generate_service.rb
+36
-0
spec/services/boards/lists/generate_service_spec.rb
spec/services/boards/lists/generate_service_spec.rb
+40
-0
No files found.
app/services/boards/lists/generate_service.rb
0 → 100644
View file @
68cfdba7
module
Boards
module
Lists
class
GenerateService
<
Boards
::
BaseService
def
execute
return
false
unless
board
.
lists
.
label
.
empty?
List
.
transaction
do
label_params
.
each
{
|
params
|
create_list
(
params
)
}
end
true
end
private
def
create_list
(
params
)
label
=
find_or_create_label
(
params
)
CreateService
.
new
(
project
,
user
,
label_id:
label
.
id
).
execute
end
def
find_or_create_label
(
params
)
project
.
labels
.
create_with
(
color:
params
[
:color
])
.
find_or_create_by
(
name:
params
[
:name
])
end
def
label_params
[
{
name:
'Development'
,
color:
'#5CB85C'
},
{
name:
'Testing'
,
color:
'#F0AD4E'
},
{
name:
'Production'
,
color:
'#FF5F00'
},
{
name:
'Ready'
,
color:
'#FF0000'
}
]
end
end
end
end
spec/services/boards/lists/generate_service_spec.rb
0 → 100644
View file @
68cfdba7
require
'spec_helper'
describe
Boards
::
Lists
::
GenerateService
,
services:
true
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:board
)
{
project
.
board
}
let
(
:user
)
{
create
(
:user
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
context
'when board lists is empty'
do
it
'creates the default lists'
do
expect
{
service
.
execute
}.
to
change
(
board
.
lists
,
:count
).
by
(
4
)
end
end
context
'when board lists is not empty'
do
it
'does not creates the default lists'
do
create
(
:list
,
board:
board
)
expect
{
service
.
execute
}.
not_to
change
(
board
.
lists
,
:count
)
end
end
context
'when project labels does not contains any list label'
do
it
'creates labels'
do
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
4
)
end
end
context
'when project labels contains some of list label'
do
it
'creates the missing labels'
do
create
(
:label
,
project:
project
,
name:
'Development'
)
create
(
:label
,
project:
project
,
name:
'Ready'
)
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
2
)
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