Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
eccfab44
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,发现更多精彩内容 >>
提交
eccfab44
编写于
2月 16, 2019
作者:
N
Nermin Vehabovic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added: Specs for sort page breaks on notes
上级
44b2d759
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
11 deletion
+43
-11
lib/api/helpers.rb
lib/api/helpers.rb
+6
-6
spec/support/shared_examples/requests/api/notes.rb
spec/support/shared_examples/requests/api/notes.rb
+37
-5
未找到文件。
lib/api/helpers.rb
浏览文件 @
eccfab44
...
...
@@ -299,6 +299,12 @@ module API
items
.
search
(
text
)
end
def
order_options_with_tie_breaker
order_options
=
{
params
[
:order_by
]
=>
params
[
:sort
]
}
order_options
[
'id'
]
||=
'desc'
order_options
end
# error helpers
def
forbidden!
(
reason
=
nil
)
...
...
@@ -397,12 +403,6 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
def
order_options_with_tie_breaker
order_options
=
{
params
[
:order_by
]
=>
params
[
:sort
]
}
order_options
[
'id'
]
||=
'desc'
order_options
end
def
project_finder_params
finder_params
=
{
without_deleted:
true
}
finder_params
[
:owned
]
=
true
if
params
[
:owned
].
present?
...
...
spec/support/shared_examples/requests/api/notes.rb
浏览文件 @
eccfab44
...
...
@@ -8,13 +8,45 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
create_list
(
:note
,
3
,
params
)
end
it
'sorts by created_at in descending order by default'
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
noteable_type
}
/
#{
noteable
[
id_name
]
}
/notes"
,
user
)
context
'without sort params'
do
it
'sorts by created_at in descending order by default'
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
noteable_type
}
/
#{
noteable
[
id_name
]
}
/notes"
,
user
)
response_dates
=
json_response
.
map
{
|
note
|
note
[
'created_at'
]
}
response_dates
=
json_response
.
map
{
|
note
|
note
[
'created_at'
]
}
expect
(
json_response
.
length
).
to
eq
(
4
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
expect
(
json_response
.
length
).
to
eq
(
4
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
context
'2 notes with equal created_at'
do
before
do
@first_note
=
Note
.
first
params
=
{
noteable:
noteable
,
author:
user
}
params
[
:project
]
=
parent
if
parent
.
is_a?
(
Project
)
params
[
:created_at
]
=
@first_note
.
created_at
@note2
=
create
(
:note
,
params
)
end
it
'page breaks first page correctly'
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
noteable_type
}
/
#{
noteable
[
id_name
]
}
/notes?per_page=4"
,
user
)
response_ids
=
json_response
.
map
{
|
note
|
note
[
'id'
]
}
expect
(
response_ids
).
to
include
(
@note2
.
id
)
expect
(
response_ids
).
not_to
include
(
@first_note
.
id
)
end
it
'page breaks second page correctly'
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
noteable_type
}
/
#{
noteable
[
id_name
]
}
/notes?per_page=4&page=2"
,
user
)
response_ids
=
json_response
.
map
{
|
note
|
note
[
'id'
]
}
expect
(
response_ids
).
not_to
include
(
@note2
.
id
)
expect
(
response_ids
).
to
include
(
@first_note
.
id
)
end
end
end
it
'sorts by ascending order when requested'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录