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
91107463
Commit
91107463
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Boards::Lists::CreateService to create lists for a specific board
parent
a2c48547
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
13 deletions
+12
-13
app/services/boards/base_service.rb
app/services/boards/base_service.rb
+0
-1
app/services/boards/lists/create_service.rb
app/services/boards/lists/create_service.rb
+5
-5
spec/services/boards/lists/create_service_spec.rb
spec/services/boards/lists/create_service_spec.rb
+7
-7
No files found.
app/services/boards/base_service.rb
View file @
91107463
module
Boards
class
BaseService
<
::
BaseService
delegate
:board
,
to: :project
end
end
app/services/boards/lists/create_service.rb
View file @
91107463
module
Boards
module
Lists
class
CreateService
<
Boards
::
BaseService
def
execute
def
execute
(
board
)
List
.
transaction
do
label
=
project
.
labels
.
find
(
params
[
:label_id
])
position
=
next_position
position
=
next_position
(
board
)
create_list
(
label
,
position
)
create_list
(
board
,
label
,
position
)
end
end
private
def
next_position
def
next_position
(
board
)
max_position
=
board
.
lists
.
movable
.
maximum
(
:position
)
max_position
.
nil?
?
0
:
max_position
.
succ
end
def
create_list
(
label
,
position
)
def
create_list
(
board
,
label
,
position
)
board
.
lists
.
create
(
label:
label
,
list_type: :label
,
position:
position
)
end
end
...
...
spec/services/boards/lists/create_service_spec.rb
View file @
91107463
...
...
@@ -2,8 +2,8 @@ require 'spec_helper'
describe
Boards
::
Lists
::
CreateService
,
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
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'in-progress'
)
}
...
...
@@ -11,7 +11,7 @@ describe Boards::Lists::CreateService, services: true do
context
'when board lists is empty'
do
it
'creates a new list at beginning of the list'
do
list
=
service
.
execute
list
=
service
.
execute
(
board
)
expect
(
list
.
position
).
to
eq
0
end
...
...
@@ -19,7 +19,7 @@ describe Boards::Lists::CreateService, services: true do
context
'when board lists has backlog, and done lists'
do
it
'creates a new list at beginning of the list'
do
list
=
service
.
execute
list
=
service
.
execute
(
board
)
expect
(
list
.
position
).
to
eq
0
end
...
...
@@ -30,7 +30,7 @@ describe Boards::Lists::CreateService, services: true do
create
(
:list
,
board:
board
,
position:
0
)
create
(
:list
,
board:
board
,
position:
1
)
list
=
service
.
execute
list
=
service
.
execute
(
board
)
expect
(
list
.
position
).
to
eq
2
end
...
...
@@ -40,7 +40,7 @@ describe Boards::Lists::CreateService, services: true do
it
'creates a new list at end of the label lists'
do
list1
=
create
(
:list
,
board:
board
,
position:
0
)
list2
=
service
.
execute
list2
=
service
.
execute
(
board
)
expect
(
list1
.
reload
.
position
).
to
eq
0
expect
(
list2
.
reload
.
position
).
to
eq
1
...
...
@@ -52,7 +52,7 @@ describe Boards::Lists::CreateService, services: true do
label
=
create
(
:label
,
name:
'in-development'
)
service
=
described_class
.
new
(
project
,
user
,
label_id:
label
.
id
)
expect
{
service
.
execute
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
service
.
execute
(
board
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
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