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
af6762f7
Commit
af6762f7
authored
Feb 13, 2020
by
Eugenia Grieff
Committed by
Robert Speicher
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor merge requests api requests specs
Resuse existing methods defined in api_helper
parent
3c8faad1
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
195 deletions
+135
-195
ee/spec/requests/api/merge_requests_spec.rb
ee/spec/requests/api/merge_requests_spec.rb
+7
-13
spec/requests/api/issues/issues_spec.rb
spec/requests/api/issues/issues_spec.rb
+2
-7
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+115
-175
spec/support/helpers/api_helpers.rb
spec/support/helpers/api_helpers.rb
+11
-0
No files found.
ee/spec/requests/api/merge_requests_spec.rb
View file @
af6762f7
...
...
@@ -212,12 +212,6 @@ describe API::MergeRequests do
end
context
'when authenticated'
do
def
expect_response_contain_exactly
(
*
items
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
map
{
|
element
|
element
[
'id'
]
}).
to
contain_exactly
(
*
items
.
map
(
&
:id
))
expect
(
json_response
.
length
).
to
eq
(
items
.
size
)
end
context
'filter merge requests by assignee ID'
do
let!
(
:merge_request2
)
do
create
(
:merge_request
,
:simple
,
assignees:
[
user2
],
source_project:
project
,
target_project:
project
,
source_branch:
'other-branch-2'
)
...
...
@@ -226,7 +220,7 @@ describe API::MergeRequests do
it
'returns merge requests with given assignee ID'
do
get
api
(
'/merge_requests'
,
user
),
params:
{
assignee_id:
user2
.
id
}
expect_
response_contain_exactly
(
merge_request
,
merge_request2
)
expect_
paginated_array_response
([
merge_request2
.
id
,
merge_request
.
id
]
)
end
end
...
...
@@ -243,7 +237,7 @@ describe API::MergeRequests do
let
(
:approvers_param
)
{
[
merge_request_with_approver
.
approvers
.
first
.
user_id
]
}
it
'returns an array of merge requests which have specified the user as an approver'
do
expect_
response_contain_exactly
(
merge_request_with_approver
)
expect_
paginated_array_response
([
merge_request_with_approver
.
id
]
)
end
end
...
...
@@ -251,7 +245,7 @@ describe API::MergeRequests do
let
(
:approvers_param
)
{
'None'
}
it
'returns an array of merge requests with no approvers'
do
expect_
response_contain_exactly
(
merge_request
)
expect_
paginated_array_response
([
merge_request
.
id
]
)
end
end
...
...
@@ -259,7 +253,7 @@ describe API::MergeRequests do
let
(
:approvers_param
)
{
'Any'
}
it
'returns an array of merge requests with any approver'
do
expect_
response_contain_exactly
(
merge_request_with_approver
)
expect_
paginated_array_response
([
merge_request_with_approver
.
id
]
)
end
end
...
...
@@ -288,7 +282,7 @@ describe API::MergeRequests do
let
(
:approvals_param
)
{
[
user2
.
id
]
}
it
'returns an array of merge requests which have specified the user as an approver'
do
expect_
response_contain_exactly
(
merge_request_with_approval
)
expect_
paginated_array_response
([
merge_request_with_approval
.
id
]
)
end
end
...
...
@@ -296,7 +290,7 @@ describe API::MergeRequests do
let
(
:approvals_param
)
{
'None'
}
it
'returns an array of merge requests with no approvers'
do
expect_
response_contain_exactly
(
merge_request
)
expect_
paginated_array_response
([
merge_request
.
id
]
)
end
end
...
...
@@ -304,7 +298,7 @@ describe API::MergeRequests do
let
(
:approvals_param
)
{
'Any'
}
it
'returns an array of merge requests with any approver'
do
expect_
response_contain_exactly
(
merge_request_with_approval
)
expect_
paginated_array_response
([
merge_request_with_approval
.
id
]
)
end
end
...
...
spec/requests/api/issues/issues_spec.rb
View file @
af6762f7
...
...
@@ -795,13 +795,13 @@ describe API::Issues do
it
'returns issues from non archived projects only by default'
do
get
api
(
"/groups/
#{
group1
.
id
}
/issues"
,
user
),
params:
{
scope:
'all'
}
expect_
response_contain_exactly
(
issue2
,
issue1
)
expect_
paginated_array_response
([
issue2
.
id
,
issue1
.
id
]
)
end
it
'returns issues from archived and non archived projects when non_archived is false'
do
get
api
(
"/groups/
#{
group1
.
id
}
/issues"
,
user
),
params:
{
non_archived:
false
,
scope:
'all'
}
expect_
response_contain_exactly
(
issue1
,
issue2
,
issue3
)
expect_
paginated_array_response
([
issue3
.
id
,
issue2
.
id
,
issue1
.
id
]
)
end
end
end
...
...
@@ -888,9 +888,4 @@ describe API::Issues do
include_examples
'time tracking endpoints'
,
'issue'
end
def
expect_response_contain_exactly
(
*
items
)
expect
(
json_response
.
length
).
to
eq
(
items
.
size
)
expect
(
json_response
.
map
{
|
element
|
element
[
'id'
]
}).
to
contain_exactly
(
*
items
.
map
(
&
:id
))
end
end
spec/requests/api/merge_requests_spec.rb
View file @
af6762f7
This diff is collapsed.
Click to expand it.
spec/support/helpers/api_helpers.rb
View file @
af6762f7
...
...
@@ -40,6 +40,17 @@ module ApiHelpers
end
end
def
expect_empty_array_response
expect_successful_response_with_paginated_array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
def
expect_successful_response_with_paginated_array
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
end
def
expect_paginated_array_response
(
items
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
...
...
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