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
255cac63
Commit
255cac63
authored
Apr 01, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
f69766ce
9763c9cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
changelogs/unreleased/sh-fix-project-branches-merge-status.yml
...elogs/unreleased/sh-fix-project-branches-merge-status.yml
+5
-0
lib/api/branches.rb
lib/api/branches.rb
+2
-2
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+23
-3
No files found.
changelogs/unreleased/sh-fix-project-branches-merge-status.yml
0 → 100644
View file @
255cac63
---
title
:
Fix API /project/:id/branches not returning correct merge status
merge_request
:
26785
author
:
type
:
fixed
lib/api/branches.rb
View file @
255cac63
...
...
@@ -34,11 +34,11 @@ module API
repository
=
user_project
.
repository
branches
=
BranchesFinder
.
new
(
repository
,
declared_params
(
include_missing:
false
)).
execute
branches
=
::
Kaminari
.
paginate_array
(
branches
)
branches
=
paginate
(
::
Kaminari
.
paginate_array
(
branches
)
)
merged_branch_names
=
repository
.
merged_branch_names
(
branches
.
map
(
&
:name
))
present
(
paginate
(
branches
)
,
branches
,
with:
Entities
::
Branch
,
current_user:
current_user
,
project:
user_project
,
...
...
spec/requests/api/branches_spec.rb
View file @
255cac63
...
...
@@ -20,9 +20,9 @@ describe API::Branches do
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/branches"
}
shared_examples_for
'repository branches'
do
RSpec
::
Matchers
.
define
:has_merged_branch_names_count
do
|
expected
|
RSpec
::
Matchers
.
define
:has_
up_to_
merged_branch_names_count
do
|
expected
|
match
do
|
actual
|
actual
[
:merged_branch_names
].
count
==
expected
expected
>=
actual
[
:merged_branch_names
].
count
end
end
...
...
@@ -36,10 +36,30 @@ describe API::Branches do
expect
(
branch_names
).
to
match_array
(
project
.
repository
.
branch_names
)
end
def
check_merge_status
(
json_response
)
merged
,
unmerged
=
json_response
.
partition
{
|
branch
|
branch
[
'merged'
]
}
merged_branches
=
merged
.
map
{
|
branch
|
branch
[
'name'
]
}
unmerged_branches
=
unmerged
.
map
{
|
branch
|
branch
[
'name'
]
}
expect
(
Set
.
new
(
merged_branches
)).
to
eq
(
project
.
repository
.
merged_branch_names
(
merged_branches
+
unmerged_branches
))
expect
(
project
.
repository
.
merged_branch_names
(
unmerged_branches
)).
to
be_empty
end
it
'determines only a limited number of merged branch names'
do
expect
(
API
::
Entities
::
Branch
).
to
receive
(
:represent
).
with
(
anything
,
has_
merged_branch_names_count
(
2
))
expect
(
API
::
Entities
::
Branch
).
to
receive
(
:represent
).
with
(
anything
,
has_
up_to_merged_branch_names_count
(
2
)).
and_call_original
get
api
(
route
,
current_user
),
params:
{
per_page:
2
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
check_merge_status
(
json_response
)
end
it
'merge status matches reality on paginated input'
do
get
api
(
route
,
current_user
),
params:
{
per_page:
20
,
page:
2
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
check_merge_status
(
json_response
)
end
context
'when repository is disabled'
do
...
...
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