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
b23683b0
Commit
b23683b0
authored
Jul 27, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add service to remove a list from board
parent
279361fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
app/services/boards/lists/destroy_service.rb
app/services/boards/lists/destroy_service.rb
+34
-0
spec/services/boards/lists/destroy_service_spec.rb
spec/services/boards/lists/destroy_service_spec.rb
+30
-0
No files found.
app/services/boards/lists/destroy_service.rb
0 → 100644
View file @
b23683b0
module
Boards
module
Lists
class
DestroyService
def
initialize
(
project
,
params
=
{})
@board
=
project
.
board
@params
=
params
.
dup
end
def
execute
list
.
with_lock
do
reorder_higher_lists
remove_list
end
end
private
attr_reader
:board
,
:params
def
list
@list
||=
board
.
lists
.
find
(
params
[
:list_id
])
end
def
reorder_higher_lists
board
.
lists
.
where
(
'position > ?'
,
list
.
position
)
.
update_all
(
'position = position - 1'
)
end
def
remove_list
list
.
destroy
end
end
end
end
spec/services/boards/lists/destroy_service_spec.rb
0 → 100644
View file @
b23683b0
require
'spec_helper'
describe
Boards
::
Lists
::
DestroyService
,
services:
true
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:board
)
{
project
.
board
}
it
'removes list from board'
do
list
=
create
(
:list
,
board:
board
)
service
=
described_class
.
new
(
project
,
list_id:
list
.
id
)
expect
{
service
.
execute
}.
to
change
(
board
.
lists
,
:count
).
by
(
-
1
)
end
it
'decrements position of higher lists'
do
list1
=
create
(
:list
,
board:
board
,
position:
1
)
list2
=
create
(
:list
,
board:
board
,
position:
2
)
list3
=
create
(
:list
,
board:
board
,
position:
3
)
list4
=
create
(
:list
,
board:
board
,
position:
4
)
list5
=
create
(
:list
,
board:
board
,
position:
5
)
described_class
.
new
(
project
,
list_id:
list2
.
id
).
execute
expect
(
list1
.
reload
.
position
).
to
eq
1
expect
(
list3
.
reload
.
position
).
to
eq
2
expect
(
list4
.
reload
.
position
).
to
eq
3
expect
(
list5
.
reload
.
position
).
to
eq
4
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