Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b2fb3a9c
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,发现更多精彩内容 >>
提交
b2fb3a9c
编写于
3月 28, 2019
作者:
F
Felipe Artur
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review comments
上级
16a3fea3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
23 deletion
+14
-23
app/models/concerns/issuable_states.rb
app/models/concerns/issuable_states.rb
+3
-5
lib/gitlab/background_migration/sync_issues_state_id.rb
lib/gitlab/background_migration/sync_issues_state_id.rb
+1
-1
spec/migrations/schedule_sync_issuables_state_id_spec.rb
spec/migrations/schedule_sync_issuables_state_id_spec.rb
+10
-17
未找到文件。
app/models/concerns/issuable_states.rb
浏览文件 @
b2fb3a9c
...
...
@@ -17,11 +17,9 @@ module IssuableStates
# Needed to prevent breaking some migration specs that
# rollback database to a point where state_id does not exist.
# We can use this guard clause for now since this file will
# be removed
on a future
the next release.
return
unless
self
.
respond_to
?
(
:state_id
)
# be removed
in
the next release.
return
unless
self
.
has_attribute
?
(
:state_id
)
states_hash
=
self
.
class
.
available_states
self
.
state_id
=
states_hash
[
state
]
self
.
state_id
=
self
.
class
.
available_states
[
state
]
end
end
lib/gitlab/background_migration/sync_issues_state_id.rb
浏览文件 @
b2fb3a9c
...
...
@@ -5,7 +5,7 @@ module Gitlab
module
BackgroundMigration
class
SyncIssuesStateId
def
perform
(
start_id
,
end_id
)
Rails
.
l
ogger
.
info
(
"Issues - Populating state_id:
#{
start_id
}
-
#{
end_id
}
"
)
Gitlab
::
AppL
ogger
.
info
(
"Issues - Populating state_id:
#{
start_id
}
-
#{
end_id
}
"
)
ActiveRecord
::
Base
.
connection
.
execute
<<~
SQL
UPDATE issues
...
...
spec/migrations/schedule_sync_issuables_state_id_spec.rb
浏览文件 @
b2fb3a9c
...
...
@@ -9,11 +9,8 @@ describe ScheduleSyncIssuablesStateId, :migration do
let
(
:merge_requests
)
{
table
(
:merge_requests
)
}
let
(
:issues
)
{
table
(
:issues
)
}
let
(
:migration
)
{
described_class
.
new
}
before
do
@group
=
namespaces
.
create!
(
name:
'gitlab'
,
path:
'gitlab'
)
@project
=
projects
.
create!
(
namespace_id:
@group
.
id
)
end
let
(
:group
)
{
namespaces
.
create!
(
name:
'gitlab'
,
path:
'gitlab'
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
group
.
id
)
}
shared_examples
'scheduling migrations'
do
before
do
...
...
@@ -40,14 +37,12 @@ describe ScheduleSyncIssuablesStateId, :migration do
opened_issue
=
issues
.
create!
(
description:
'first'
,
state:
'opened'
)
closed_issue
=
issues
.
create!
(
description:
'second'
,
state:
'closed'
)
invalid_state_issue
=
issues
.
create!
(
description:
'fourth'
,
state:
'not valid'
)
nil_state_issue
=
issues
.
create!
(
description:
'third'
,
state:
nil
)
migrate!
expect
(
opened_issue
.
reload
.
state_id
).
to
eq
(
Issue
.
available_states
[
:opened
])
expect
(
closed_issue
.
reload
.
state_id
).
to
eq
(
Issue
.
available_states
[
:closed
])
expect
(
invalid_state_issue
.
reload
.
state_id
).
to
be_nil
expect
(
nil_state_issue
.
reload
.
state_id
).
to
be_nil
end
it_behaves_like
'scheduling migrations'
do
...
...
@@ -61,11 +56,10 @@ describe ScheduleSyncIssuablesStateId, :migration do
context
'merge requests'
do
it
'migrates state column to integer'
do
opened_merge_request
=
merge_requests
.
create!
(
state:
'opened'
,
target_project_id:
@project
.
id
,
target_branch:
'feature1'
,
source_branch:
'master'
)
closed_merge_request
=
merge_requests
.
create!
(
state:
'closed'
,
target_project_id:
@project
.
id
,
target_branch:
'feature2'
,
source_branch:
'master'
)
merged_merge_request
=
merge_requests
.
create!
(
state:
'merged'
,
target_project_id:
@project
.
id
,
target_branch:
'feature3'
,
source_branch:
'master'
)
locked_merge_request
=
merge_requests
.
create!
(
state:
'locked'
,
target_project_id:
@project
.
id
,
target_branch:
'feature4'
,
source_branch:
'master'
)
invalid_state_merge_request
=
merge_requests
.
create!
(
state:
'not valid'
,
target_project_id:
@project
.
id
,
target_branch:
'feature5'
,
source_branch:
'master'
)
opened_merge_request
=
merge_requests
.
create!
(
state:
'opened'
,
target_project_id:
project
.
id
,
target_branch:
'feature1'
,
source_branch:
'master'
)
closed_merge_request
=
merge_requests
.
create!
(
state:
'closed'
,
target_project_id:
project
.
id
,
target_branch:
'feature2'
,
source_branch:
'master'
)
merged_merge_request
=
merge_requests
.
create!
(
state:
'merged'
,
target_project_id:
project
.
id
,
target_branch:
'feature3'
,
source_branch:
'master'
)
locked_merge_request
=
merge_requests
.
create!
(
state:
'locked'
,
target_project_id:
project
.
id
,
target_branch:
'feature4'
,
source_branch:
'master'
)
migrate!
...
...
@@ -73,15 +67,14 @@ describe ScheduleSyncIssuablesStateId, :migration do
expect
(
closed_merge_request
.
reload
.
state_id
).
to
eq
(
MergeRequest
.
available_states
[
:closed
])
expect
(
merged_merge_request
.
reload
.
state_id
).
to
eq
(
MergeRequest
.
available_states
[
:merged
])
expect
(
locked_merge_request
.
reload
.
state_id
).
to
eq
(
MergeRequest
.
available_states
[
:locked
])
expect
(
invalid_state_merge_request
.
reload
.
state_id
).
to
be_nil
end
it_behaves_like
'scheduling migrations'
do
let
(
:migration
)
{
described_class
::
MERGE_REQUESTS_MIGRATION
}
let!
(
:resource_1
)
{
merge_requests
.
create!
(
state:
'opened'
,
target_project_id:
@
project
.
id
,
target_branch:
'feature1'
,
source_branch:
'master'
)
}
let!
(
:resource_2
)
{
merge_requests
.
create!
(
state:
'closed'
,
target_project_id:
@
project
.
id
,
target_branch:
'feature2'
,
source_branch:
'master'
)
}
let!
(
:resource_3
)
{
merge_requests
.
create!
(
state:
'merged'
,
target_project_id:
@
project
.
id
,
target_branch:
'feature3'
,
source_branch:
'master'
)
}
let!
(
:resource_4
)
{
merge_requests
.
create!
(
state:
'locked'
,
target_project_id:
@
project
.
id
,
target_branch:
'feature4'
,
source_branch:
'master'
)
}
let!
(
:resource_1
)
{
merge_requests
.
create!
(
state:
'opened'
,
target_project_id:
project
.
id
,
target_branch:
'feature1'
,
source_branch:
'master'
)
}
let!
(
:resource_2
)
{
merge_requests
.
create!
(
state:
'closed'
,
target_project_id:
project
.
id
,
target_branch:
'feature2'
,
source_branch:
'master'
)
}
let!
(
:resource_3
)
{
merge_requests
.
create!
(
state:
'merged'
,
target_project_id:
project
.
id
,
target_branch:
'feature3'
,
source_branch:
'master'
)
}
let!
(
:resource_4
)
{
merge_requests
.
create!
(
state:
'locked'
,
target_project_id:
project
.
id
,
target_branch:
'feature4'
,
source_branch:
'master'
)
}
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录