Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
996240a4
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,体验更适合开发者的 AI 搜索 >>
提交
996240a4
编写于
4月 27, 2016
作者:
F
Felipe Artur
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issues/MRs filter when ordering by milestone due date
上级
baa9c660
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
4 deletion
+45
-4
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+2
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+40
-1
未找到文件。
app/finders/issuable_finder.rb
浏览文件 @
996240a4
...
@@ -253,9 +253,9 @@ class IssuableFinder
...
@@ -253,9 +253,9 @@ class IssuableFinder
items
=
items
.
where
(
milestone_id:
[
-
1
,
nil
])
items
=
items
.
where
(
milestone_id:
[
-
1
,
nil
])
elsif
filter_by_upcoming_milestone?
elsif
filter_by_upcoming_milestone?
upcoming_ids
=
Milestone
.
upcoming_ids_by_projects
(
projects
)
upcoming_ids
=
Milestone
.
upcoming_ids_by_projects
(
projects
)
items
=
items
.
joins
(
:milestone
)
.
where
(
milestone_id:
upcoming_ids
)
items
=
items
.
left_joins_milestones
.
where
(
milestone_id:
upcoming_ids
)
else
else
items
=
items
.
joins
(
:milestone
)
.
where
(
milestones:
{
title:
params
[
:milestone_title
]
})
items
=
items
.
left_joins_milestones
.
where
(
milestones:
{
title:
params
[
:milestone_title
]
})
if
projects
if
projects
items
=
items
.
where
(
milestones:
{
project_id:
projects
})
items
=
items
.
where
(
milestones:
{
project_id:
projects
})
...
...
app/models/concerns/issuable.rb
浏览文件 @
996240a4
...
@@ -35,10 +35,12 @@ module Issuable
...
@@ -35,10 +35,12 @@ module Issuable
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:left_joins_milestones
,
->
{
joins
(
"LEFT OUTER JOIN milestones ON
#{
table_name
}
.milestone_id = milestones.id"
)
}
scope
:order_milestone_due_desc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date DESC, milestones.id DESC'
)
}
scope
:order_milestone_due_desc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date DESC, milestones.id DESC'
)
}
scope
:order_milestone_due_asc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date ASC, milestones.id ASC'
)
}
scope
:order_milestone_due_asc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date ASC, milestones.id ASC'
)
}
scope
:without_label
,
->
{
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
name
}
' AND label_links.target_id =
#{
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
}
scope
:without_label
,
->
{
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
name
}
' AND label_links.target_id =
#{
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
}
scope
:join_project
,
->
{
joins
(
:project
)
}
scope
:join_project
,
->
{
joins
(
:project
)
}
scope
:references_project
,
->
{
references
(
:project
)
}
scope
:references_project
,
->
{
references
(
:project
)
}
scope
:non_archived
,
->
{
join_project
.
where
(
projects:
{
archived:
false
})
}
scope
:non_archived
,
->
{
join_project
.
where
(
projects:
{
archived:
false
})
}
...
...
spec/models/concerns/issuable_spec.rb
浏览文件 @
996240a4
require
'spec_helper'
require
'spec_helper'
describe
Issue
,
"Issuable"
do
describe
Issue
,
"Issuable"
do
let
(
:issue
)
{
create
(
:issue
)
}
let
!
(
:issue
)
{
create
(
:issue
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
"Associations"
do
describe
"Associations"
do
...
@@ -114,6 +114,45 @@ describe Issue, "Issuable" do
...
@@ -114,6 +114,45 @@ describe Issue, "Issuable" do
end
end
end
end
describe
"#sort"
do
#Correct order is:
#Issues/MRs with milestones ordered by date
#Issues/MRs with milestones without dates
#Issues/MRs without milestones
let
(
:project
)
{
issue
.
project
}
let!
(
:early_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
10
.
days
.
from_now
)
}
let!
(
:late_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
30
.
days
.
from_now
)
}
let!
(
:issue1
)
{
create
(
:issue
,
project:
project
,
milestone:
early_milestone
)
}
let!
(
:issue2
)
{
create
(
:issue
,
project:
project
,
milestone:
late_milestone
)
}
let!
(
:issue3
)
{
create
(
:issue
,
project:
project
)
}
context
"milestone due later"
do
subject
{
Issue
.
where
(
project_id:
project
.
id
).
order_milestone_due_desc
}
before
{
@issues
=
subject
}
it
"puts issues with nil values at the end of collection"
do
expect
(
@issues
.
first
).
to
eq
(
issue2
)
expect
(
@issues
.
second
).
to
eq
(
issue1
)
expect
(
@issues
.
third
).
to
eq
(
issue
)
expect
(
@issues
.
fourth
).
to
eq
(
issue3
)
end
end
context
"milestone due soon"
do
subject
{
Issue
.
where
(
project_id:
project
.
id
).
order_milestone_due_asc
}
before
{
@issues
=
subject
}
it
"puts issues with nil values at the end of collection"
do
expect
(
@issues
.
first
).
to
eq
(
issue1
)
expect
(
@issues
.
second
).
to
eq
(
issue2
)
expect
(
@issues
.
third
).
to
eq
(
issue
)
expect
(
@issues
.
fourth
).
to
eq
(
issue3
)
end
end
end
describe
'#subscribed?'
do
describe
'#subscribed?'
do
context
'user is not a participant in the issue'
do
context
'user is not a participant in the issue'
do
before
{
allow
(
issue
).
to
receive
(
:participants
).
with
(
user
).
and_return
([])
}
before
{
allow
(
issue
).
to
receive
(
:participants
).
with
(
user
).
and_return
([])
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录