Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
91107463
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91107463
编写于
10月 05, 2016
作者:
D
Douglas Barbosa Alexandre
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update Boards::Lists::CreateService to create lists for a specific board
上级
a2c48547
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
12 addition
and
13 deletion
+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
未找到文件。
app/services/boards/base_service.rb
浏览文件 @
91107463
module
Boards
class
BaseService
<
::
BaseService
delegate
:board
,
to: :project
end
end
app/services/boards/lists/create_service.rb
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录