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
f77c47a5
Commit
f77c47a5
authored
Aug 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove lookup inside services to keep them consistent with other ones
parent
affed370
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
81 deletions
+75
-81
app/controllers/projects/boards/issues_controller.rb
app/controllers/projects/boards/issues_controller.rb
+6
-2
app/controllers/projects/boards/lists_controller.rb
app/controllers/projects/boards/lists_controller.rb
+8
-3
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+2
-6
app/services/boards/lists/destroy_service.rb
app/services/boards/lists/destroy_service.rb
+5
-9
app/services/boards/lists/move_service.rb
app/services/boards/lists/move_service.rb
+7
-14
spec/services/boards/issues/move_service_spec.rb
spec/services/boards/issues/move_service_spec.rb
+18
-18
spec/services/boards/lists/destroy_service_spec.rb
spec/services/boards/lists/destroy_service_spec.rb
+7
-7
spec/services/boards/lists/move_service_spec.rb
spec/services/boards/lists/move_service_spec.rb
+22
-22
No files found.
app/controllers/projects/boards/issues_controller.rb
View file @
f77c47a5
...
@@ -19,7 +19,7 @@ module Projects
...
@@ -19,7 +19,7 @@ module Projects
def
update
def
update
service
=
::
Boards
::
Issues
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
service
=
::
Boards
::
Issues
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
if
service
.
execute
(
issue
)
head
:ok
head
:ok
else
else
head
:unprocessable_entity
head
:unprocessable_entity
...
@@ -28,12 +28,16 @@ module Projects
...
@@ -28,12 +28,16 @@ module Projects
private
private
def
issue
@issue
||=
project
.
issues
.
visible_to_user
(
current_user
).
find_by!
(
iid:
params
[
:id
])
end
def
authorize_read_issue!
def
authorize_read_issue!
return
render_403
unless
can?
(
current_user
,
:read_issue
,
project
)
return
render_403
unless
can?
(
current_user
,
:read_issue
,
project
)
end
end
def
authorize_update_issue!
def
authorize_update_issue!
return
render_403
unless
can?
(
current_user
,
:update_issue
,
project
)
return
render_403
unless
can?
(
current_user
,
:update_issue
,
issue
)
end
end
def
filter_params
def
filter_params
...
...
app/controllers/projects/boards/lists_controller.rb
View file @
f77c47a5
...
@@ -3,6 +3,7 @@ module Projects
...
@@ -3,6 +3,7 @@ module Projects
class
ListsController
<
Boards
::
ApplicationController
class
ListsController
<
Boards
::
ApplicationController
before_action
:authorize_admin_list!
,
only:
[
:create
,
:update
,
:destroy
,
:generate
]
before_action
:authorize_admin_list!
,
only:
[
:create
,
:update
,
:destroy
,
:generate
]
before_action
:authorize_read_list!
,
only:
[
:index
]
before_action
:authorize_read_list!
,
only:
[
:index
]
before_action
:load_list
,
only:
[
:update
,
:destroy
]
def
index
def
index
render
json:
serialize_as_json
(
project
.
board
.
lists
)
render
json:
serialize_as_json
(
project
.
board
.
lists
)
...
@@ -21,7 +22,7 @@ module Projects
...
@@ -21,7 +22,7 @@ module Projects
def
update
def
update
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
if
service
.
execute
(
@list
)
head
:ok
head
:ok
else
else
head
:unprocessable_entity
head
:unprocessable_entity
...
@@ -31,7 +32,7 @@ module Projects
...
@@ -31,7 +32,7 @@ module Projects
def
destroy
def
destroy
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
,
params
)
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
,
params
)
if
service
.
execute
if
service
.
execute
(
@list
)
head
:ok
head
:ok
else
else
head
:unprocessable_entity
head
:unprocessable_entity
...
@@ -58,12 +59,16 @@ module Projects
...
@@ -58,12 +59,16 @@ module Projects
return
render_403
unless
can?
(
current_user
,
:read_list
,
project
)
return
render_403
unless
can?
(
current_user
,
:read_list
,
project
)
end
end
def
load_list
@list
=
project
.
board
.
lists
.
find
(
params
[
:id
])
end
def
list_params
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
params
.
require
(
:list
).
permit
(
:label_id
)
end
end
def
move_params
def
move_params
params
.
require
(
:list
).
permit
(
:position
)
.
merge
(
id:
params
[
:id
])
params
.
require
(
:list
).
permit
(
:position
)
end
end
def
serialize_as_json
(
resource
)
def
serialize_as_json
(
resource
)
...
...
app/services/boards/issues/move_service.rb
View file @
f77c47a5
module
Boards
module
Boards
module
Issues
module
Issues
class
MoveService
<
Boards
::
BaseService
class
MoveService
<
Boards
::
BaseService
def
execute
def
execute
(
issue
)
return
false
unless
issue
.
present?
return
false
unless
user
.
can?
(
:update_issue
,
issue
)
return
false
unless
valid_move?
return
false
unless
valid_move?
update_service
.
execute
(
issue
)
update_service
.
execute
(
issue
)
...
@@ -14,10 +14,6 @@ module Boards
...
@@ -14,10 +14,6 @@ module Boards
moving_from_list
.
present?
&&
moving_to_list
.
present?
moving_from_list
.
present?
&&
moving_to_list
.
present?
end
end
def
issue
@issue
||=
project
.
issues
.
visible_to_user
(
user
).
find_by!
(
iid:
params
[
:id
])
end
def
moving_from_list
def
moving_from_list
@moving_from_list
||=
board
.
lists
.
find_by
(
id:
params
[
:from_list_id
])
@moving_from_list
||=
board
.
lists
.
find_by
(
id:
params
[
:from_list_id
])
end
end
...
...
app/services/boards/lists/destroy_service.rb
View file @
f77c47a5
module
Boards
module
Boards
module
Lists
module
Lists
class
DestroyService
<
Boards
::
BaseService
class
DestroyService
<
Boards
::
BaseService
def
execute
def
execute
(
list
)
return
false
unless
list
.
label?
return
false
unless
list
.
label?
list
.
with_lock
do
list
.
with_lock
do
decrement_higher_lists
decrement_higher_lists
(
list
)
remove_list
remove_list
(
list
)
end
end
end
end
private
private
def
list
def
decrement_higher_lists
(
list
)
@list
||=
board
.
lists
.
find
(
params
[
:id
])
end
def
decrement_higher_lists
board
.
lists
.
label
.
where
(
'position > ?'
,
list
.
position
)
board
.
lists
.
label
.
where
(
'position > ?'
,
list
.
position
)
.
update_all
(
'position = position - 1'
)
.
update_all
(
'position = position - 1'
)
end
end
def
remove_list
def
remove_list
(
list
)
list
.
destroy
list
.
destroy
end
end
end
end
...
...
app/services/boards/lists/move_service.rb
View file @
f77c47a5
module
Boards
module
Boards
module
Lists
module
Lists
class
MoveService
<
Boards
::
BaseService
class
MoveService
<
Boards
::
BaseService
def
execute
def
execute
(
list
)
@old_position
=
list
.
position
@new_position
=
params
[
:position
]
return
false
unless
list
.
label?
return
false
unless
list
.
label?
return
false
unless
valid_move?
return
false
unless
valid_move?
list
.
with_lock
do
list
.
with_lock
do
reorder_intermediate_lists
reorder_intermediate_lists
update_list_position
update_list_position
(
list
)
end
end
end
end
private
private
def
list
attr_reader
:old_position
,
:new_position
@list
||=
board
.
lists
.
find
(
params
[
:id
])
end
def
valid_move?
def
valid_move?
new_position
.
present?
&&
new_position
!=
old_position
&&
new_position
.
present?
&&
new_position
!=
old_position
&&
new_position
>=
0
&&
new_position
<
board
.
lists
.
label
.
size
new_position
>=
0
&&
new_position
<
board
.
lists
.
label
.
size
end
end
def
old_position
@old_position
||=
list
.
position
end
def
new_position
@new_position
||=
params
[
:position
]
end
def
reorder_intermediate_lists
def
reorder_intermediate_lists
if
old_position
<
new_position
if
old_position
<
new_position
decrement_intermediate_lists
decrement_intermediate_lists
...
@@ -50,7 +43,7 @@ module Boards
...
@@ -50,7 +43,7 @@ module Boards
.
update_all
(
'position = position + 1'
)
.
update_all
(
'position = position + 1'
)
end
end
def
update_list_position
def
update_list_position
(
list
)
list
.
update_attribute
(
:position
,
new_position
)
list
.
update_attribute
(
:position
,
new_position
)
end
end
end
end
...
...
spec/services/boards/issues/move_service_spec.rb
View file @
f77c47a5
...
@@ -22,9 +22,9 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -22,9 +22,9 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from backlog'
do
context
'when moving from backlog'
do
it
'adds the label of the list it goes to'
do
it
'adds the label of the list it goes to'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
params
=
{
id:
issue
.
iid
,
from_list_id:
backlog
.
id
,
to_list_id:
list1
.
id
}
params
=
{
from_list_id:
backlog
.
id
,
to_list_id:
list1
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
,
development
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
,
development
)
end
end
...
@@ -33,9 +33,9 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -33,9 +33,9 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving to backlog'
do
context
'when moving to backlog'
do
it
'removes all list-labels'
do
it
'removes all list-labels'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
params
=
{
id:
issue
.
iid
,
from_list_id:
list1
.
id
,
to_list_id:
backlog
.
id
}
params
=
{
from_list_id:
list1
.
id
,
to_list_id:
backlog
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
)
end
end
...
@@ -44,9 +44,9 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -44,9 +44,9 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from backlog to done'
do
context
'when moving from backlog to done'
do
it
'closes the issue'
do
it
'closes the issue'
do
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
params
=
{
id:
issue
.
iid
,
from_list_id:
backlog
.
id
,
to_list_id:
done
.
id
}
params
=
{
from_list_id:
backlog
.
id
,
to_list_id:
done
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
...
@@ -56,16 +56,16 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -56,16 +56,16 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving an issue between lists'
do
context
'when moving an issue between lists'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
])
}
let
(
:params
)
{
{
id:
issue
.
iid
,
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
}
}
let
(
:params
)
{
{
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
}
}
it
'delegates the label changes to Issues::UpdateService'
do
it
'delegates the label changes to Issues::UpdateService'
do
expect_any_instance_of
(
Issues
::
UpdateService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
UpdateService
).
to
receive
(
:execute
).
with
(
issue
).
once
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
end
end
it
'removes
s
the label from the list it came from and adds the label of the list it goes to'
do
it
'removes the label from the list it came from and adds the label of the list it goes to'
do
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
,
testing
)
expect
(
issue
.
reload
.
labels
).
to
contain_exactly
(
bug
,
testing
)
end
end
...
@@ -73,16 +73,16 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -73,16 +73,16 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving to done'
do
context
'when moving to done'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
,
development
,
testing
])
}
let
(
:params
)
{
{
id:
issue
.
iid
,
from_list_id:
list2
.
id
,
to_list_id:
done
.
id
}
}
let
(
:params
)
{
{
from_list_id:
list2
.
id
,
to_list_id:
done
.
id
}
}
it
'delegates the close proceedings to Issues::CloseService'
do
it
'delegates the close proceedings to Issues::CloseService'
do
expect_any_instance_of
(
Issues
::
CloseService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
CloseService
).
to
receive
(
:execute
).
with
(
issue
).
once
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
end
end
it
'removes all list-labels and close the issue'
do
it
'removes all list-labels and close the issue'
do
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
...
@@ -92,16 +92,16 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -92,16 +92,16 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from done'
do
context
'when moving from done'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let
(
:issue
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let
(
:params
)
{
{
id:
issue
.
iid
,
from_list_id:
done
.
id
,
to_list_id:
list2
.
id
}
}
let
(
:params
)
{
{
from_list_id:
done
.
id
,
to_list_id:
list2
.
id
}
}
it
'delegates the re-open proceedings to Issues::ReopenService'
do
it
'delegates the re-open proceedings to Issues::ReopenService'
do
expect_any_instance_of
(
Issues
::
ReopenService
).
to
receive
(
:execute
).
with
(
issue
).
once
expect_any_instance_of
(
Issues
::
ReopenService
).
to
receive
(
:execute
).
with
(
issue
).
once
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
end
end
it
'adds the label of the list it goes to and reopen the issue'
do
it
'adds the label of the list it goes to and reopen the issue'
do
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
,
testing
)
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
,
testing
)
...
@@ -112,9 +112,9 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -112,9 +112,9 @@ describe Boards::Issues::MoveService, services: true do
context
'when moving from done to backlog'
do
context
'when moving from done to backlog'
do
it
'reopens the issue'
do
it
'reopens the issue'
do
issue
=
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
issue
=
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
params
=
{
id:
issue
.
iid
,
from_list_id:
done
.
id
,
to_list_id:
backlog
.
id
}
params
=
{
from_list_id:
done
.
id
,
to_list_id:
backlog
.
id
}
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
)
issue
.
reload
issue
.
reload
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
expect
(
issue
.
labels
).
to
contain_exactly
(
bug
)
...
...
spec/services/boards/lists/destroy_service_spec.rb
View file @
f77c47a5
...
@@ -9,9 +9,9 @@ describe Boards::Lists::DestroyService, services: true do
...
@@ -9,9 +9,9 @@ describe Boards::Lists::DestroyService, services: true do
context
'when list type is label'
do
context
'when list type is label'
do
it
'removes list from board'
do
it
'removes list from board'
do
list
=
create
(
:list
,
board:
board
)
list
=
create
(
:list
,
board:
board
)
service
=
described_class
.
new
(
project
,
user
,
id:
list
.
id
)
service
=
described_class
.
new
(
project
,
user
)
expect
{
service
.
execute
}.
to
change
(
board
.
lists
,
:count
).
by
(
-
1
)
expect
{
service
.
execute
(
list
)
}.
to
change
(
board
.
lists
,
:count
).
by
(
-
1
)
end
end
it
'decrements position of higher lists'
do
it
'decrements position of higher lists'
do
...
@@ -21,7 +21,7 @@ describe Boards::Lists::DestroyService, services: true do
...
@@ -21,7 +21,7 @@ describe Boards::Lists::DestroyService, services: true do
staging
=
create
(
:list
,
board:
board
,
position:
2
)
staging
=
create
(
:list
,
board:
board
,
position:
2
)
done
=
create
(
:done_list
,
board:
board
)
done
=
create
(
:done_list
,
board:
board
)
described_class
.
new
(
project
,
user
,
id:
development
.
id
).
execute
described_class
.
new
(
project
,
user
).
execute
(
development
)
expect
(
backlog
.
reload
.
position
).
to
be_nil
expect
(
backlog
.
reload
.
position
).
to
be_nil
expect
(
review
.
reload
.
position
).
to
eq
0
expect
(
review
.
reload
.
position
).
to
eq
0
...
@@ -32,16 +32,16 @@ describe Boards::Lists::DestroyService, services: true do
...
@@ -32,16 +32,16 @@ describe Boards::Lists::DestroyService, services: true do
it
'does not remove list from board when list type is backlog'
do
it
'does not remove list from board when list type is backlog'
do
list
=
create
(
:backlog_list
,
board:
board
)
list
=
create
(
:backlog_list
,
board:
board
)
service
=
described_class
.
new
(
project
,
user
,
id:
list
.
id
)
service
=
described_class
.
new
(
project
,
user
)
expect
{
service
.
execute
}.
not_to
change
(
board
.
lists
,
:count
)
expect
{
service
.
execute
(
list
)
}.
not_to
change
(
board
.
lists
,
:count
)
end
end
it
'does not remove list from board when list type is done'
do
it
'does not remove list from board when list type is done'
do
list
=
create
(
:done_list
,
board:
board
)
list
=
create
(
:done_list
,
board:
board
)
service
=
described_class
.
new
(
project
,
user
,
id:
list
.
id
)
service
=
described_class
.
new
(
project
,
user
)
expect
{
service
.
execute
}.
not_to
change
(
board
.
lists
,
:count
)
expect
{
service
.
execute
(
list
)
}.
not_to
change
(
board
.
lists
,
:count
)
end
end
end
end
end
end
spec/services/boards/lists/move_service_spec.rb
View file @
f77c47a5
...
@@ -15,90 +15,90 @@ describe Boards::Lists::MoveService, services: true do
...
@@ -15,90 +15,90 @@ describe Boards::Lists::MoveService, services: true do
context
'when list type is set to label'
do
context
'when list type is set to label'
do
it
'keeps position of lists when new position is nil'
do
it
'keeps position of lists when new position is nil'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
nil
)
service
=
described_class
.
new
(
project
,
user
,
position:
nil
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'keeps position of lists when new positon is equal to old position'
do
it
'keeps position of lists when new positon is equal to old position'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
planning
.
position
)
service
=
described_class
.
new
(
project
,
user
,
position:
planning
.
position
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'keeps position of lists when new positon is negative'
do
it
'keeps position of lists when new positon is negative'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
-
1
)
service
=
described_class
.
new
(
project
,
user
,
position:
-
1
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'keeps position of lists when new positon is equal to number of labels lists'
do
it
'keeps position of lists when new positon is equal to number of labels lists'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
board
.
lists
.
label
.
size
)
service
=
described_class
.
new
(
project
,
user
,
position:
board
.
lists
.
label
.
size
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'keeps position of lists when new positon is greater than number of labels lists'
do
it
'keeps position of lists when new positon is greater than number of labels lists'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
board
.
lists
.
label
.
size
+
1
)
service
=
described_class
.
new
(
project
,
user
,
position:
board
.
lists
.
label
.
size
+
1
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'increments position of intermediate lists when new positon is equal to first position'
do
it
'increments position of intermediate lists when new positon is equal to first position'
do
service
=
described_class
.
new
(
project
,
user
,
id:
staging
.
id
,
position:
0
)
service
=
described_class
.
new
(
project
,
user
,
position:
0
)
service
.
execute
service
.
execute
(
staging
)
expect
(
current_list_positions
).
to
eq
[
1
,
2
,
3
,
0
]
expect
(
current_list_positions
).
to
eq
[
1
,
2
,
3
,
0
]
end
end
it
'decrements position of intermediate lists when new positon is equal to last position'
do
it
'decrements position of intermediate lists when new positon is equal to last position'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
board
.
lists
.
label
.
last
.
position
)
service
=
described_class
.
new
(
project
,
user
,
position:
board
.
lists
.
label
.
last
.
position
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
3
,
0
,
1
,
2
]
expect
(
current_list_positions
).
to
eq
[
3
,
0
,
1
,
2
]
end
end
it
'decrements position of intermediate lists when new position is greater than old position'
do
it
'decrements position of intermediate lists when new position is greater than old position'
do
service
=
described_class
.
new
(
project
,
user
,
id:
planning
.
id
,
position:
2
)
service
=
described_class
.
new
(
project
,
user
,
position:
2
)
service
.
execute
service
.
execute
(
planning
)
expect
(
current_list_positions
).
to
eq
[
2
,
0
,
1
,
3
]
expect
(
current_list_positions
).
to
eq
[
2
,
0
,
1
,
3
]
end
end
it
'increments position of intermediate lists when new position is lower than old position'
do
it
'increments position of intermediate lists when new position is lower than old position'
do
service
=
described_class
.
new
(
project
,
user
,
id:
staging
.
id
,
position:
1
)
service
=
described_class
.
new
(
project
,
user
,
position:
1
)
service
.
execute
service
.
execute
(
staging
)
expect
(
current_list_positions
).
to
eq
[
0
,
2
,
3
,
1
]
expect
(
current_list_positions
).
to
eq
[
0
,
2
,
3
,
1
]
end
end
end
end
it
'keeps position of lists when list type is backlog'
do
it
'keeps position of lists when list type is backlog'
do
service
=
described_class
.
new
(
project
,
user
,
id:
backlog
.
id
,
position:
2
)
service
=
described_class
.
new
(
project
,
user
,
position:
2
)
service
.
execute
service
.
execute
(
backlog
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
end
end
it
'keeps position of lists when list type is done'
do
it
'keeps position of lists when list type is done'
do
service
=
described_class
.
new
(
project
,
user
,
id:
done
.
id
,
position:
2
)
service
=
described_class
.
new
(
project
,
user
,
position:
2
)
service
.
execute
service
.
execute
(
done
)
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
expect
(
current_list_positions
).
to
eq
[
0
,
1
,
2
,
3
]
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