Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c70dfbc6
Commit
c70dfbc6
authored
Jan 24, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a custom pagination matcher
parent
01ea65e0
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
274 additions
and
36 deletions
+274
-36
spec/requests/api/access_requests_spec.rb
spec/requests/api/access_requests_spec.rb
+1
-0
spec/requests/api/award_emoji_spec.rb
spec/requests/api/award_emoji_spec.rb
+1
-0
spec/requests/api/boards_spec.rb
spec/requests/api/boards_spec.rb
+2
-0
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+2
-0
spec/requests/api/broadcast_messages_spec.rb
spec/requests/api/broadcast_messages_spec.rb
+1
-0
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+2
-0
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+3
-3
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+1
-0
spec/requests/api/deploy_keys_spec.rb
spec/requests/api/deploy_keys_spec.rb
+2
-0
spec/requests/api/deployments_spec.rb
spec/requests/api/deployments_spec.rb
+1
-0
spec/requests/api/environments_spec.rb
spec/requests/api/environments_spec.rb
+1
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+17
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+88
-14
spec/requests/api/labels_spec.rb
spec/requests/api/labels_spec.rb
+1
-0
spec/requests/api/members_spec.rb
spec/requests/api/members_spec.rb
+7
-0
spec/requests/api/merge_request_diffs_spec.rb
spec/requests/api/merge_request_diffs_spec.rb
+2
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+26
-0
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+19
-0
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+8
-4
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+5
-0
spec/requests/api/project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+1
-0
spec/requests/api/project_snippets_spec.rb
spec/requests/api/project_snippets_spec.rb
+6
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+19
-2
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+4
-3
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+10
-5
spec/requests/api/snippets_spec.rb
spec/requests/api/snippets_spec.rb
+7
-0
spec/requests/api/system_hooks_spec.rb
spec/requests/api/system_hooks_spec.rb
+1
-0
spec/requests/api/tags_spec.rb
spec/requests/api/tags_spec.rb
+6
-4
spec/requests/api/templates_spec.rb
spec/requests/api/templates_spec.rb
+4
-0
spec/requests/api/todos_spec.rb
spec/requests/api/todos_spec.rb
+6
-0
spec/requests/api/triggers_spec.rb
spec/requests/api/triggers_spec.rb
+1
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+14
-0
spec/support/matchers/pagination_matcher.rb
spec/support/matchers/pagination_matcher.rb
+5
-0
No files found.
spec/requests/api/access_requests_spec.rb
View file @
c70dfbc6
...
...
@@ -48,6 +48,7 @@ describe API::AccessRequests, api: true do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/access_requests"
,
master
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
end
...
...
spec/requests/api/award_emoji_spec.rb
View file @
c70dfbc6
...
...
@@ -34,6 +34,7 @@ describe API::AwardEmoji, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/award_emoji"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
downvote
.
name
)
end
...
...
spec/requests/api/boards_spec.rb
View file @
c70dfbc6
...
...
@@ -55,6 +55,7 @@ describe API::Boards, api: true do
get
api
(
base_url
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
board
.
id
)
...
...
@@ -72,6 +73,7 @@ describe API::Boards, api: true do
get
api
(
base_url
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'label'
][
'name'
]).
to
eq
(
dev_label
.
title
)
...
...
spec/requests/api/branches_spec.rb
View file @
c70dfbc6
...
...
@@ -18,7 +18,9 @@ describe API::Branches, api: true do
project
.
repository
.
expire_all_method_caches
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
),
per_page:
100
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
branch_names
=
json_response
.
map
{
|
x
|
x
[
'name'
]
}
expect
(
branch_names
).
to
match_array
(
project
.
repository
.
branch_names
)
...
...
spec/requests/api/broadcast_messages_spec.rb
View file @
c70dfbc6
...
...
@@ -25,6 +25,7 @@ describe API::BroadcastMessages, api: true do
get
api
(
'/broadcast_messages'
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_kind_of
(
Array
)
expect
(
json_response
.
first
.
keys
)
.
to
match_array
(
%w(id message starts_at ends_at color font active)
)
...
...
spec/requests/api/builds_spec.rb
View file @
c70dfbc6
...
...
@@ -22,6 +22,7 @@ describe API::Builds, api: true do
context
'authorized user'
do
it
'returns project builds'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
end
...
...
@@ -97,6 +98,7 @@ describe API::Builds, api: true do
it
'returns project jobs for specific commit'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
2
end
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
c70dfbc6
...
...
@@ -54,7 +54,7 @@ describe API::CommitStatuses, api: true do
it
'returns all commit statuses'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status1
.
id
,
status2
.
id
,
status3
.
id
,
status4
.
id
,
...
...
@@ -67,7 +67,7 @@ describe API::CommitStatuses, api: true do
it
'returns latest commit statuses for specific ref'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status3
.
id
,
status5
.
id
)
end
...
...
@@ -78,7 +78,7 @@ describe API::CommitStatuses, api: true do
it
'return latest commit statuses for specific name'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status4
.
id
,
status5
.
id
)
end
...
...
spec/requests/api/commits_spec.rb
View file @
c70dfbc6
...
...
@@ -456,6 +456,7 @@ describe API::Commits, api: true do
it
'returns merge_request comments'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
/comments"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
'a comment on a commit'
)
...
...
spec/requests/api/deploy_keys_spec.rb
View file @
c70dfbc6
...
...
@@ -35,6 +35,7 @@ describe API::DeployKeys, api: true do
get
api
(
'/deploy_keys'
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
deploy_keys_project
.
deploy_key
.
id
)
end
...
...
@@ -48,6 +49,7 @@ describe API::DeployKeys, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/deploy_keys"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
deploy_key
.
title
)
end
...
...
spec/requests/api/deployments_spec.rb
View file @
c70dfbc6
...
...
@@ -22,6 +22,7 @@ describe API::Deployments, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'iid'
]).
to
eq
(
deployment
.
iid
)
...
...
spec/requests/api/environments_spec.rb
View file @
c70dfbc6
...
...
@@ -22,6 +22,7 @@ describe API::Environments, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
environment
.
name
)
...
...
spec/requests/api/groups_spec.rb
View file @
c70dfbc6
...
...
@@ -33,6 +33,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
)
...
...
@@ -43,6 +44,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
),
statistics:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
not_to
include
'statistics'
end
...
...
@@ -53,6 +55,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -61,6 +64,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
not_to
include
(
'statistics'
)
end
...
...
@@ -78,6 +82,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
admin
),
statistics:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
)
.
to
satisfy_one
{
|
group
|
group
[
'statistics'
]
==
attributes
}
...
...
@@ -89,6 +94,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
admin
),
skip_groups:
[
group2
.
id
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
@@ -103,6 +109,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
),
all_available:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_groups
).
to
contain_exactly
(
public_group
.
name
,
group1
.
name
)
end
...
...
@@ -120,6 +127,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_groups
).
to
eq
([
group3
.
name
,
group1
.
name
])
end
...
...
@@ -128,6 +136,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
),
sort:
"desc"
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_groups
).
to
eq
([
group1
.
name
,
group3
.
name
])
end
...
...
@@ -136,6 +145,7 @@ describe API::Groups, api: true do
get
api
(
"/groups"
,
user1
),
order_by:
"path"
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_groups
).
to
eq
([
group1
.
name
,
group3
.
name
])
end
...
...
@@ -156,6 +166,7 @@ describe API::Groups, api: true do
get
api
(
'/groups/owned'
,
user2
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
group2
.
name
)
end
...
...
@@ -290,6 +301,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
2
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
...
...
@@ -300,6 +312,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
simple:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
2
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
...
...
@@ -312,6 +325,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
),
visibility:
'public'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
public_project
.
name
)
...
...
@@ -335,6 +349,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user3
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project3
.
name
)
end
...
...
@@ -365,6 +380,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group2
.
id
}
/projects"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project2
.
name
)
end
...
...
@@ -381,6 +397,7 @@ describe API::Groups, api: true do
get
api
(
"/groups/
#{
group1
.
path
}
/projects"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
end
...
...
spec/requests/api/issues_spec.rb
View file @
c70dfbc6
...
...
@@ -68,7 +68,9 @@ describe API::Issues, api: true do
context
"when authenticated"
do
it
"returns an array of issues"
do
get
api
(
"/issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
...
...
@@ -76,7 +78,9 @@ describe API::Issues, api: true do
it
'returns an array of closed issues'
do
get
api
(
'/issues?state=closed'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
...
...
@@ -84,7 +88,9 @@ describe API::Issues, api: true do
it
'returns an array of opened issues'
do
get
api
(
'/issues?state=opened'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
...
...
@@ -92,7 +98,9 @@ describe API::Issues, api: true do
it
'returns an array of all issues'
do
get
api
(
'/issues?state=all'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
...
...
@@ -101,7 +109,9 @@ describe API::Issues, api: true do
it
'returns an array of labeled issues'
do
get
api
(
"/issues?labels=
#{
label
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
...
...
@@ -111,6 +121,7 @@ describe API::Issues, api: true do
get
api
(
"/issues?labels=
#{
label
.
title
}
,foo,bar"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
...
...
@@ -118,14 +129,18 @@ describe API::Issues, api: true do
it
'returns an empty array if no issue matches labels'
do
get
api
(
'/issues?labels=foo,bar'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an array of labeled issues matching given state'
do
get
api
(
"/issues?labels=
#{
label
.
title
}
&state=opened"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
...
...
@@ -134,7 +149,9 @@ describe API::Issues, api: true do
it
'returns an empty array if no issue matches labels and state filters'
do
get
api
(
"/issues?labels=
#{
label
.
title
}
&state=closed"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -143,6 +160,7 @@ describe API::Issues, api: true do
get
api
(
"/issues?milestone=
#{
empty_milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -151,6 +169,7 @@ describe API::Issues, api: true do
get
api
(
"/issues?milestone=foo"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -159,6 +178,7 @@ describe API::Issues, api: true do
get
api
(
"/issues?milestone=
#{
milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
...
...
@@ -170,6 +190,7 @@ describe API::Issues, api: true do
'&state=closed'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
...
...
@@ -179,6 +200,7 @@ describe API::Issues, api: true do
get
api
(
"/issues?milestone=
#{
no_milestone_title
}
"
,
author
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
...
...
@@ -186,36 +208,40 @@ describe API::Issues, api: true do
it
'sorts by created_at descending by default'
do
get
api
(
'/issues'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
...
...
@@ -269,6 +295,7 @@ describe API::Issues, api: true do
get
api
(
base_url
,
non_member
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
group_issue
.
title
)
...
...
@@ -278,6 +305,7 @@ describe API::Issues, api: true do
get
api
(
base_url
,
author
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -286,6 +314,7 @@ describe API::Issues, api: true do
get
api
(
base_url
,
assignee
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -294,6 +323,7 @@ describe API::Issues, api: true do
get
api
(
base_url
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -302,6 +332,7 @@ describe API::Issues, api: true do
get
api
(
base_url
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -310,6 +341,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?labels=
#{
group_label
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
group_label
.
title
])
...
...
@@ -319,6 +351,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?labels=
#{
group_label
.
title
}
,foo,bar"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -327,6 +360,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?labels=foo,bar"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -335,6 +369,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?milestone=
#{
group_empty_milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -343,6 +378,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?milestone=foo"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -351,6 +387,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?milestone=
#{
group_milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
...
...
@@ -361,6 +398,7 @@ describe API::Issues, api: true do
'&state=closed'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_closed_issue
.
id
)
...
...
@@ -370,6 +408,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
?milestone=
#{
no_milestone_title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_confidential_issue
.
id
)
...
...
@@ -377,36 +416,40 @@ describe API::Issues, api: true do
it
'sorts by created_at descending by default'
do
get
api
(
base_url
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
...
...
@@ -430,12 +473,17 @@ describe API::Issues, api: true do
get
api
(
"/projects/
#{
restricted_project
.
id
}
/issues"
,
non_member
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
eq
([])
end
it
'returns project issues without confidential issues for non project members'
do
get
api
(
"
#{
base_url
}
/issues"
,
non_member
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -443,7 +491,9 @@ describe API::Issues, api: true do
it
'returns project issues without confidential issues for project members with guest role'
do
get
api
(
"
#{
base_url
}
/issues"
,
guest
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -451,7 +501,9 @@ describe API::Issues, api: true do
it
'returns project confidential issues for author'
do
get
api
(
"
#{
base_url
}
/issues"
,
author
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -459,7 +511,9 @@ describe API::Issues, api: true do
it
'returns project confidential issues for assignee'
do
get
api
(
"
#{
base_url
}
/issues"
,
assignee
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -467,7 +521,9 @@ describe API::Issues, api: true do
it
'returns project issues with confidential issues for project members'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -475,7 +531,9 @@ describe API::Issues, api: true do
it
'returns project confidential issues for admin'
do
get
api
(
"
#{
base_url
}
/issues"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
@@ -483,7 +541,9 @@ describe API::Issues, api: true do
it
'returns an array of labeled project issues'
do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
...
...
@@ -493,6 +553,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo,bar"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
...
...
@@ -500,21 +561,27 @@ describe API::Issues, api: true do
it
'returns an empty array if no project issue matches labels'
do
get
api
(
"
#{
base_url
}
/issues?labels=foo,bar"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an empty array if no issue matches milestone'
do
get
api
(
"
#{
base_url
}
/issues?milestone=
#{
empty_milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an empty array if milestone does not exist'
do
get
api
(
"
#{
base_url
}
/issues?milestone=foo"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -523,6 +590,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
/issues?milestone=
#{
milestone
.
title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
...
...
@@ -530,9 +598,10 @@ describe API::Issues, api: true do
end
it
'returns an array of issues matching state in milestone'
do
get
api
(
"
#{
base_url
}
/issues?milestone=
#{
milestone
.
title
}
"
\
'&state=closed'
,
user
)
get
api
(
"
#{
base_url
}
/issues?milestone=
#{
milestone
.
title
}
&state=closed"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
...
...
@@ -542,6 +611,7 @@ describe API::Issues, api: true do
get
api
(
"
#{
base_url
}
/issues?milestone=
#{
no_milestone_title
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
...
...
@@ -549,36 +619,40 @@ describe API::Issues, api: true do
it
'sorts by created_at descending by default'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
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'
]
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
...
...
spec/requests/api/labels_spec.rb
View file @
c70dfbc6
...
...
@@ -30,6 +30,7 @@ describe API::Labels, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
first
.
keys
).
to
match_array
expected_keys
...
...
spec/requests/api/members_spec.rb
View file @
c70dfbc6
...
...
@@ -34,9 +34,12 @@ describe API::Members, api: true do
context
"when authenticated as a
#{
type
}
"
do
it
'returns 200'
do
user
=
public_send
(
type
)
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
map
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
master
.
id
,
developer
.
id
]
end
...
...
@@ -49,6 +52,8 @@ describe API::Members, api: true do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
developer
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
map
{
|
u
|
u
[
'id'
]
}).
to
match_array
[
master
.
id
,
developer
.
id
]
end
...
...
@@ -57,6 +62,8 @@ describe API::Members, api: true do
get
api
(
"/
#{
source_type
.
pluralize
}
/
#{
source
.
id
}
/members"
,
developer
),
query:
master
.
username
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'username'
]).
to
eq
(
master
.
username
)
end
...
...
spec/requests/api/merge_request_diffs_spec.rb
View file @
c70dfbc6
...
...
@@ -19,6 +19,8 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs', api: true do
merge_request_diff
=
merge_request
.
merge_request_diffs
.
first
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
merge_request
.
merge_request_diffs
.
size
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
merge_request_diff
.
id
)
expect
(
json_response
.
first
[
'head_commit_sha'
]).
to
eq
(
merge_request_diff
.
head_commit_sha
)
...
...
spec/requests/api/merge_requests_spec.rb
View file @
c70dfbc6
...
...
@@ -27,7 +27,9 @@ describe API::MergeRequests, api: true do
context
"when authenticated"
do
it
"returns an array of all merge_requests"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
last
[
'title'
]).
to
eq
(
merge_request
.
title
)
...
...
@@ -43,7 +45,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of all merge_requests"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?state"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
.
last
[
'title'
]).
to
eq
(
merge_request
.
title
)
...
...
@@ -51,7 +55,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of open merge_requests"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?state=opened"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
last
[
'title'
]).
to
eq
(
merge_request
.
title
)
...
...
@@ -59,7 +65,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of closed merge_requests"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?state=closed"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
merge_request_closed
.
title
)
...
...
@@ -67,7 +75,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of merged merge_requests"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?state=merged"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
merge_request_merged
.
title
)
...
...
@@ -91,7 +101,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of merge_requests in ascending order"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?sort=asc"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
response_dates
=
json_response
.
map
{
|
merge_request
|
merge_request
[
'created_at'
]
}
...
...
@@ -100,7 +112,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of merge_requests in descending order"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?sort=desc"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
response_dates
=
json_response
.
map
{
|
merge_request
|
merge_request
[
'created_at'
]
}
...
...
@@ -109,7 +123,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of merge_requests ordered by updated_at"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?order_by=updated_at"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
response_dates
=
json_response
.
map
{
|
merge_request
|
merge_request
[
'updated_at'
]
}
...
...
@@ -118,7 +134,9 @@ describe API::MergeRequests, api: true do
it
"returns an array of merge_requests ordered by created_at"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests?order_by=created_at&sort=asc"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
response_dates
=
json_response
.
map
{
|
merge_request
|
merge_request
[
'created_at'
]
}
...
...
@@ -207,6 +225,7 @@ describe API::MergeRequests, api: true do
describe
'GET /projects/:id/merge_requests/:merge_request_id/changes'
do
it
'returns the change information of the merge_request'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/changes"
,
user
)
expect
(
response
.
status
).
to
eq
200
expect
(
json_response
[
'changes'
].
size
).
to
eq
(
merge_request
.
diffs
.
size
)
end
...
...
@@ -574,7 +593,9 @@ describe API::MergeRequests, api: true do
it
"returns merge_request comments ordered by created_at"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/comments"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'note'
]).
to
eq
(
"a comment on a MR"
)
...
...
@@ -596,7 +617,9 @@ describe API::MergeRequests, api: true do
end
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
mr
.
id
}
/closes_issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
...
...
@@ -604,7 +627,9 @@ describe API::MergeRequests, api: true do
it
'returns an empty array when there are no issues to be closed'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
...
...
@@ -618,6 +643,7 @@ describe API::MergeRequests, api: true do
get
api
(
"/projects/
#{
jira_project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
...
...
spec/requests/api/milestones_spec.rb
View file @
c70dfbc6
...
...
@@ -14,6 +14,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/milestones"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
milestone
.
title
)
end
...
...
@@ -28,6 +29,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/milestones?state=active"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
milestone
.
id
)
...
...
@@ -37,6 +39,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/milestones?state=closed"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_milestone
.
id
)
...
...
@@ -46,6 +49,8 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/milestones?iid=
#{
closed_milestone
.
iid
}
"
,
user
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
closed_milestone
.
title
expect
(
json_response
.
first
[
'id'
]).
to
eq
closed_milestone
.
id
...
...
@@ -59,6 +64,16 @@ describe API::Milestones, api: true do
expect
(
json_response
.
first
[
'title'
]).
to
eq
milestone
.
title
expect
(
json_response
.
first
[
'id'
]).
to
eq
milestone
.
id
end
it
'returns a project milestone by iid array'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones"
,
user
),
iid:
[
milestone
.
iid
,
closed_milestone
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
milestone
.
title
expect
(
json_response
.
first
[
'id'
]).
to
eq
milestone
.
id
end
end
describe
'GET /projects/:id/milestones/:milestone_id'
do
...
...
@@ -177,6 +192,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
/issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'milestone'
][
'title'
]).
to
eq
(
milestone
.
title
)
end
...
...
@@ -202,6 +218,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
public_project
.
id
}
/milestones/
#{
milestone
.
id
}
/issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}).
to
include
(
issue
.
id
,
confidential_issue
.
id
)
...
...
@@ -214,6 +231,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
public_project
.
id
}
/milestones/
#{
milestone
.
id
}
/issues"
,
member
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}).
to
include
(
issue
.
id
)
...
...
@@ -223,6 +241,7 @@ describe API::Milestones, api: true do
get
api
(
"/projects/
#{
public_project
.
id
}
/milestones/
#{
milestone
.
id
}
/issues"
,
create
(
:user
))
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}).
to
include
(
issue
.
id
)
...
...
spec/requests/api/namespaces_spec.rb
View file @
c70dfbc6
...
...
@@ -18,17 +18,19 @@ describe API::Namespaces, api: true do
context
"when authenticated as admin"
do
it
"admin: returns an array of all namespaces"
do
get
api
(
"/namespaces"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
Namespace
.
count
)
end
it
"admin: returns an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
group2
.
name
}
"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
last
[
'path'
]).
to
eq
(
group2
.
path
)
expect
(
json_response
.
last
[
'full_path'
]).
to
eq
(
group2
.
full_path
)
...
...
@@ -38,17 +40,19 @@ describe API::Namespaces, api: true do
context
"when authenticated as a regular user"
do
it
"user: returns an array of namespaces"
do
get
api
(
"/namespaces"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
it
"admin: returns an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
user
.
username
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
end
...
...
spec/requests/api/notes_spec.rb
View file @
c70dfbc6
...
...
@@ -41,6 +41,7 @@ describe API::Notes, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'body'
]).
to
eq
(
issue_note
.
note
)
end
...
...
@@ -56,6 +57,7 @@ describe API::Notes, api: true do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
id
}
/notes"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_empty
end
...
...
@@ -75,6 +77,7 @@ describe API::Notes, api: true do
get
api
(
"/projects/
#{
ext_proj
.
id
}
/issues/
#{
ext_issue
.
id
}
/notes"
,
private_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'body'
]).
to
eq
(
cross_reference_note
.
note
)
end
...
...
@@ -87,6 +90,7 @@ describe API::Notes, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/notes"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'body'
]).
to
eq
(
snippet_note
.
note
)
end
...
...
@@ -109,6 +113,7 @@ describe API::Notes, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/notes"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'body'
]).
to
eq
(
merge_request_note
.
note
)
end
...
...
spec/requests/api/project_hooks_spec.rb
View file @
c70dfbc6
...
...
@@ -25,6 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
"http://example.com"
)
expect
(
json_response
.
first
[
'issues_events'
]).
to
eq
(
true
)
...
...
spec/requests/api/project_snippets_spec.rb
View file @
c70dfbc6
...
...
@@ -16,9 +16,11 @@ describe API::ProjectSnippets, api: true do
internal_snippet
=
create
(
:project_snippet
,
:internal
,
project:
project
)
private_snippet
=
create
(
:project_snippet
,
:private
,
project:
project
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets
/
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
map
{
|
snippet
|
snippet
[
'id'
]}
).
to
include
(
public_snippet
.
id
,
internal_snippet
.
id
,
private_snippet
.
id
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
...
...
@@ -28,7 +30,10 @@ describe API::ProjectSnippets, api: true do
create
(
:project_snippet
,
:private
,
project:
project
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets/"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
end
end
...
...
spec/requests/api/projects_spec.rb
View file @
c70dfbc6
...
...
@@ -76,6 +76,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
.
keys
).
to
include
(
'tag_list'
)
end
...
...
@@ -84,6 +85,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
.
keys
).
to
include
(
'open_issues_count'
)
end
...
...
@@ -94,6 +96,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
find
{
|
hash
|
hash
[
'id'
]
==
project
.
id
}.
keys
).
not_to
include
(
'open_issues_count'
)
end
...
...
@@ -102,6 +105,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
not_to
include
(
'statistics'
)
end
...
...
@@ -110,6 +114,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
statistics:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
to
include
'statistics'
end
...
...
@@ -121,6 +126,7 @@ describe API::Projects, api: true do
get
api
(
'/projects?simple=true'
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
.
keys
).
to
match_array
expected_keys
end
...
...
@@ -131,6 +137,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
search:
project
.
name
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
@@ -141,6 +148,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
visibility:
'private'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
p
|
p
[
'id'
]
}).
to
contain_exactly
(
project
.
id
,
project2
.
id
,
project3
.
id
)
end
...
...
@@ -151,6 +159,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
visibility:
'internal'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
p
|
p
[
'id'
]
}).
to
contain_exactly
(
project2
.
id
)
end
...
...
@@ -159,6 +168,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
visibility:
'public'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
p
|
p
[
'id'
]
}).
to
contain_exactly
(
public_project
.
id
)
end
...
...
@@ -169,6 +179,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
order_by:
'id'
,
sort:
'desc'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project3
.
id
)
end
...
...
@@ -179,6 +190,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user4
),
owned:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project4
.
name
)
expect
(
json_response
.
first
[
'owner'
][
'username'
]).
to
eq
(
user4
.
username
)
...
...
@@ -197,6 +209,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user3
),
starred:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
project
.
id
,
public_project
.
id
)
end
...
...
@@ -223,6 +236,7 @@ describe API::Projects, api: true do
get
api
(
'/projects'
,
user
),
{
visibility:
'public'
,
owned:
true
,
starred:
true
,
search:
'gitlab'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project5
.
id
)
...
...
@@ -644,9 +658,10 @@ describe API::Projects, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
first_event
=
json_response
.
first
expect
(
first_event
[
'action_name'
]).
to
eq
(
'commented on'
)
expect
(
first_event
[
'note'
][
'body'
]).
to
eq
(
'What an awesome day!'
)
...
...
@@ -699,11 +714,11 @@ describe API::Projects, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/users"
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
first_user
=
json_response
.
first
expect
(
first_user
[
'username'
]).
to
eq
(
member
.
username
)
expect
(
first_user
[
'name'
]).
to
eq
(
member
.
name
)
expect
(
first_user
.
keys
).
to
contain_exactly
(
*
%w[name username id state avatar_url web_url]
)
...
...
@@ -746,7 +761,9 @@ describe API::Projects, api: true do
it
'returns an array of project snippets'
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
snippet
.
title
)
end
...
...
spec/requests/api/repositories_spec.rb
View file @
c70dfbc6
...
...
@@ -19,10 +19,10 @@ describe API::Repositories, api: true do
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
first_commit
=
json_response
.
first
expect
(
json_response
).
to
be_an
Array
expect
(
first_commit
[
'name'
]).
to
eq
(
'bar'
)
expect
(
first_commit
[
'type'
]).
to
eq
(
'tree'
)
expect
(
first_commit
[
'mode'
]).
to
eq
(
'040000'
)
...
...
@@ -49,6 +49,7 @@ describe API::Repositories, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
[
4
][
'name'
]).
to
eq
(
'html'
)
expect
(
json_response
[
4
][
'path'
]).
to
eq
(
'files/html'
)
expect
(
json_response
[
4
][
'type'
]).
to
eq
(
'tree'
)
...
...
@@ -380,10 +381,10 @@ describe API::Repositories, api: true do
get
api
(
route
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
first_contributor
=
json_response
.
first
expect
(
first_contributor
[
'email'
]).
to
eq
(
'tiagonbotelho@hotmail.com'
)
expect
(
first_contributor
[
'name'
]).
to
eq
(
'tiagonbotelho'
)
expect
(
first_contributor
[
'commits'
]).
to
eq
(
1
)
...
...
spec/requests/api/runners_spec.rb
View file @
c70dfbc6
...
...
@@ -37,18 +37,20 @@ describe API::Runners, api: true do
context
'authorized user'
do
it
'returns user available runners'
do
get
api
(
'/runners'
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
it
'filters runners by scope'
do
get
api
(
'/runners?scope=active'
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
...
...
@@ -73,9 +75,10 @@ describe API::Runners, api: true do
context
'with admin privileges'
do
it
'returns all runners'
do
get
api
(
'/runners/all'
,
admin
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_truthy
end
...
...
@@ -91,9 +94,10 @@ describe API::Runners, api: true do
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=specific'
,
admin
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
...
...
@@ -335,9 +339,10 @@ describe API::Runners, api: true do
context
'authorized user with master privileges'
do
it
"returns project's runners"
do
get
api
(
"/projects/
#{
project
.
id
}
/runners"
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_truthy
end
...
...
spec/requests/api/snippets_spec.rb
View file @
c70dfbc6
...
...
@@ -13,6 +13,8 @@ describe API::Snippets, api: true do
get
api
(
"/snippets/"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
snippet
|
snippet
[
'id'
]}
).
to
contain_exactly
(
public_snippet
.
id
,
internal_snippet
.
id
,
...
...
@@ -25,7 +27,10 @@ describe API::Snippets, api: true do
create
(
:personal_snippet
,
:private
)
get
api
(
"/snippets/"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
end
end
...
...
@@ -43,6 +48,8 @@ describe API::Snippets, api: true do
get
api
(
"/snippets/public"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
snippet
|
snippet
[
'id'
]}
).
to
contain_exactly
(
public_snippet
.
id
,
public_snippet_other
.
id
)
...
...
spec/requests/api/system_hooks_spec.rb
View file @
c70dfbc6
...
...
@@ -31,6 +31,7 @@ describe API::SystemHooks, api: true do
get
api
(
"/hooks"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
.
first
[
'push_events'
]).
to
be
true
...
...
spec/requests/api/tags_spec.rb
View file @
c70dfbc6
...
...
@@ -20,10 +20,9 @@ describe API::Tags, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
first_tag
=
json_response
.
first
expect
(
first_tag
[
'name'
]).
to
eq
(
tag_name
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
tag_name
)
end
end
...
...
@@ -43,7 +42,9 @@ describe API::Tags, api: true do
context
'without releases'
do
it
"returns an array of project tags"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
tag_name
)
end
...
...
@@ -59,6 +60,7 @@ describe API::Tags, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
tag_name
)
expect
(
json_response
.
first
[
'message'
]).
to
eq
(
'Version 1.1.0'
)
...
...
spec/requests/api/templates_spec.rb
View file @
c70dfbc6
...
...
@@ -22,6 +22,7 @@ describe API::Templates, api: true do
get
api
(
'/templates/gitignores'
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
be
>
15
end
...
...
@@ -32,6 +33,7 @@ describe API::Templates, api: true do
get
api
(
'/templates/gitlab_ci_ymls'
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
not_to
be_nil
end
...
...
@@ -69,6 +71,7 @@ describe API::Templates, api: true do
get
api
(
'/templates/licenses'
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
15
)
expect
(
json_response
.
map
{
|
l
|
l
[
'key'
]
}).
to
include
(
'agpl-3.0'
)
...
...
@@ -80,6 +83,7 @@ describe API::Templates, api: true do
get
api
(
'/templates/licenses?popular=1'
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
map
{
|
l
|
l
[
'key'
]
}).
to
include
(
'apache-2.0'
)
...
...
spec/requests/api/todos_spec.rb
View file @
c70dfbc6
...
...
@@ -33,6 +33,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
3
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
pending_3
.
id
)
...
...
@@ -52,6 +53,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
),
{
author_id:
author_2
.
id
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
end
...
...
@@ -64,6 +66,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
),
{
type:
'MergeRequest'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
@@ -74,6 +77,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
),
{
state:
'done'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
@@ -84,6 +88,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
),
{
project_id:
project_2
.
id
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
@@ -94,6 +99,7 @@ describe API::Todos, api: true do
get
api
(
'/todos'
,
john_doe
),
{
action:
'mentioned'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
...
...
spec/requests/api/triggers_spec.rb
View file @
c70dfbc6
...
...
@@ -100,6 +100,7 @@ describe API::Triggers do
get
api
(
"/projects/
#{
project
.
id
}
/triggers"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_a
(
Array
)
expect
(
json_response
[
0
]).
to
have_key
(
'token'
)
end
...
...
spec/requests/api/users_spec.rb
View file @
c70dfbc6
...
...
@@ -40,7 +40,9 @@ describe API::Users, api: true do
it
"returns an array of users"
do
get
api
(
"/users"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
username
=
user
.
username
expect
(
json_response
.
detect
do
|
user
|
...
...
@@ -55,13 +57,16 @@ describe API::Users, api: true do
get
api
(
"/users?blocked=true"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
all
(
include
(
'state'
=>
/(blocked|ldap_blocked)/
))
end
it
"returns one user"
do
get
api
(
"/users?username=
#{
omniauth_user
.
username
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'username'
]).
to
eq
(
omniauth_user
.
username
)
end
...
...
@@ -70,7 +75,9 @@ describe API::Users, api: true do
context
"when admin"
do
it
"returns an array of users"
do
get
api
(
"/users"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
.
keys
).
to
include
'email'
expect
(
json_response
.
first
.
keys
).
to
include
'organization'
...
...
@@ -87,6 +94,7 @@ describe API::Users, api: true do
get
api
(
"/users?external=true"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
all
(
include
(
'external'
=>
true
))
end
...
...
@@ -598,8 +606,11 @@ describe API::Users, api: true do
it
'returns array of emails'
do
user
.
emails
<<
email
user
.
save
get
api
(
"/users/
#{
user
.
id
}
/emails"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'email'
]).
to
eq
(
email
.
email
)
end
...
...
@@ -897,8 +908,11 @@ describe API::Users, api: true do
it
"returns array of emails"
do
user
.
emails
<<
email
user
.
save
get
api
(
"/user/emails"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
"email"
]).
to
eq
(
email
.
email
)
end
...
...
spec/support/matchers/pagination_matcher.rb
0 → 100644
View file @
c70dfbc6
RSpec
::
Matchers
.
define
:include_pagination_headers
do
|
expected
|
match
do
|
actual
|
expect
(
actual
.
headers
).
to
include
(
'X-Total'
,
'X-Total-Pages'
,
'X-Per-Page'
,
'X-Page'
,
'X-Next-Page'
,
'X-Prev-Page'
,
'Link'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment