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
af87cf7c
Commit
af87cf7c
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Boards::Lists::GenerateService to generate for a specific board
parent
91107463
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
app/services/boards/lists/generate_service.rb
app/services/boards/lists/generate_service.rb
+4
-4
spec/services/boards/lists/generate_service_spec.rb
spec/services/boards/lists/generate_service_spec.rb
+6
-6
No files found.
app/services/boards/lists/generate_service.rb
View file @
af87cf7c
module
Boards
module
Lists
class
GenerateService
<
Boards
::
BaseService
def
execute
def
execute
(
board
)
return
false
unless
board
.
lists
.
movable
.
empty?
List
.
transaction
do
label_params
.
each
{
|
params
|
create_list
(
params
)
}
label_params
.
each
{
|
params
|
create_list
(
board
,
params
)
}
end
true
...
...
@@ -13,9 +13,9 @@ module Boards
private
def
create_list
(
params
)
def
create_list
(
board
,
params
)
label
=
find_or_create_label
(
params
)
Lists
::
CreateService
.
new
(
project
,
current_user
,
label_id:
label
.
id
).
execute
Lists
::
CreateService
.
new
(
project
,
current_user
,
label_id:
label
.
id
).
execute
(
board
)
end
def
find_or_create_label
(
params
)
...
...
spec/services/boards/lists/generate_service_spec.rb
View file @
af87cf7c
...
...
@@ -2,15 +2,15 @@ require 'spec_helper'
describe
Boards
::
Lists
::
GenerateService
,
services:
true
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:
project_with_board
)
}
let
(
:board
)
{
project
.
board
}
let
(
:project
)
{
create
(
:
empty_project
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
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
(
2
)
expect
{
service
.
execute
(
board
)
}.
to
change
(
board
.
lists
,
:count
).
by
(
2
)
end
end
...
...
@@ -18,13 +18,13 @@ describe Boards::Lists::GenerateService, services: true do
it
'does not creates the default lists'
do
create
(
:list
,
board:
board
)
expect
{
service
.
execute
}.
not_to
change
(
board
.
lists
,
:count
)
expect
{
service
.
execute
(
board
)
}.
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
(
2
)
expect
{
service
.
execute
(
board
)
}.
to
change
(
project
.
labels
,
:count
).
by
(
2
)
end
end
...
...
@@ -32,7 +32,7 @@ describe Boards::Lists::GenerateService, services: true do
it
'creates the missing labels'
do
create
(
:label
,
project:
project
,
name:
'Doing'
)
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
1
)
expect
{
service
.
execute
(
board
)
}.
to
change
(
project
.
labels
,
:count
).
by
(
1
)
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