Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
45fc8b73
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 搜索 >>
提交
45fc8b73
编写于
9月 09, 2016
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix API issues sorting
上级
b7e6da5a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
130 addition
and
9 deletion
+130
-9
CHANGELOG
CHANGELOG
+1
-0
lib/api/issues.rb
lib/api/issues.rb
+9
-3
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+120
-6
未找到文件。
CHANGELOG
浏览文件 @
45fc8b73
...
...
@@ -15,6 +15,7 @@ v 8.12.0 (unreleased)
- Change logo animation to CSS (ClemMakesApps)
- Instructions for enabling Git packfile bitmaps !6104
- Fix pagination on user snippets page
- Fix sorting of issues in API
- Escape search term before passing it to Regexp.new !6241 (winniehell)
- Fix pinned sidebar behavior in smaller viewports !6169
- Change merge_error column from string to text type
...
...
lib/api/issues.rb
浏览文件 @
45fc8b73
...
...
@@ -41,7 +41,8 @@ module API
issues
=
current_user
.
issues
.
inc_notes_with_associations
issues
=
filter_issues_state
(
issues
,
params
[
:state
])
unless
params
[
:state
].
nil?
issues
=
filter_issues_labels
(
issues
,
params
[
:labels
])
unless
params
[
:labels
].
nil?
issues
.
reorder
(
issuable_order_by
=>
issuable_sort
)
issues
=
issues
.
reorder
(
issuable_order_by
=>
issuable_sort
)
present
paginate
(
issues
),
with:
Entities
::
Issue
,
current_user:
current_user
end
end
...
...
@@ -73,7 +74,11 @@ module API
params
[
:group_id
]
=
group
.
id
params
[
:milestone_title
]
=
params
.
delete
(
:milestone
)
params
[
:label_name
]
=
params
.
delete
(
:labels
)
params
[
:sort
]
=
"
#{
params
.
delete
(
:order_by
)
}
_
#{
params
.
delete
(
:sort
)
}
"
if
params
[
:order_by
]
&&
params
[
:sort
]
if
params
[
:order_by
]
||
params
[
:sort
]
# The Sortable concern takes 'created_desc', not 'created_at_desc' (for example)
params
[
:sort
]
=
"
#{
issuable_order_by
.
sub
(
'_at'
,
''
)
}
_
#{
issuable_sort
}
"
end
issues
=
IssuesFinder
.
new
(
current_user
,
params
).
execute
...
...
@@ -113,7 +118,8 @@ module API
issues
=
filter_issues_milestone
(
issues
,
params
[
:milestone
])
end
issues
.
reorder
(
issuable_order_by
=>
issuable_sort
)
issues
=
issues
.
reorder
(
issuable_order_by
=>
issuable_sort
)
present
paginate
(
issues
),
with:
Entities
::
Issue
,
current_user:
current_user
end
...
...
spec/requests/api/issues_spec.rb
浏览文件 @
45fc8b73
...
...
@@ -17,21 +17,24 @@ describe API::API, api: true do
assignee:
user
,
project:
project
,
state: :closed
,
milestone:
milestone
milestone:
milestone
,
updated_at:
3
.
hours
.
ago
end
let!
(
:confidential_issue
)
do
create
:issue
,
:confidential
,
project:
project
,
author:
author
,
assignee:
assignee
assignee:
assignee
,
updated_at:
2
.
hours
.
ago
end
let!
(
:issue
)
do
create
:issue
,
author:
user
,
assignee:
user
,
project:
project
,
milestone:
milestone
milestone:
milestone
,
updated_at:
1
.
hour
.
ago
end
let!
(
:label
)
do
create
(
:label
,
title:
'label'
,
color:
'#FFAABB'
,
project:
project
)
...
...
@@ -135,6 +138,42 @@ describe API::API, api: true do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'sorts by created_at descending by default'
do
get
api
(
'/issues'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts ascending when requested'
do
get
api
(
'/issues?sort=asc'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
it
'sorts by updated_at descending when requested'
do
get
api
(
'/issues?order_by=updated_at'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts by updated_at ascending when requested'
do
get
api
(
'/issues?order_by=updated_at&sort=asc'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
end
...
...
@@ -147,21 +186,24 @@ describe API::API, api: true do
assignee:
user
,
project:
group_project
,
state: :closed
,
milestone:
group_milestone
milestone:
group_milestone
,
updated_at:
3
.
hours
.
ago
end
let!
(
:group_confidential_issue
)
do
create
:issue
,
:confidential
,
project:
group_project
,
author:
author
,
assignee:
assignee
assignee:
assignee
,
updated_at:
2
.
hours
.
ago
end
let!
(
:group_issue
)
do
create
:issue
,
author:
user
,
assignee:
user
,
project:
group_project
,
milestone:
group_milestone
milestone:
group_milestone
,
updated_at:
1
.
hour
.
ago
end
let!
(
:group_label
)
do
create
(
:label
,
title:
'group_lbl'
,
color:
'#FFAABB'
,
project:
group_project
)
...
...
@@ -278,6 +320,42 @@ describe API::API, api: true do
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_closed_issue
.
id
)
end
it
'sorts by created_at descending by default'
do
get
api
(
base_url
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts ascending when requested'
do
get
api
(
"
#{
base_url
}
?sort=asc"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
it
'sorts by updated_at descending when requested'
do
get
api
(
"
#{
base_url
}
?order_by=updated_at"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts by updated_at ascending when requested'
do
get
api
(
"
#{
base_url
}
?order_by=updated_at&sort=asc"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
describe
"GET /projects/:id/issues"
do
...
...
@@ -386,6 +464,42 @@ describe API::API, api: true do
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
it
'sorts by created_at descending by default'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts ascending when requested'
do
get
api
(
"
#{
base_url
}
/issues?sort=asc"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
it
'sorts by updated_at descending when requested'
do
get
api
(
"
#{
base_url
}
/issues?order_by=updated_at"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
it
'sorts by updated_at ascending when requested'
do
get
api
(
"
#{
base_url
}
/issues?order_by=updated_at&sort=asc"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
describe
"GET /projects/:id/issues/:issue_id"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录