Commit 9b0f8a77 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents cf21118f 08e2104e
...@@ -81,7 +81,6 @@ function deferredInitialisation() { ...@@ -81,7 +81,6 @@ function deferredInitialisation() {
initUserPopovers(); initUserPopovers();
if (document.querySelector('.search')) initSearchAutocomplete(); if (document.querySelector('.search')) initSearchAutocomplete();
if (document.querySelector('#js-peek')) initPerformanceBar({ container: '#js-peek' });
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
...@@ -148,6 +147,8 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -148,6 +147,8 @@ document.addEventListener('DOMContentLoaded', () => {
const $sidebarGutterToggle = $('.js-sidebar-toggle'); const $sidebarGutterToggle = $('.js-sidebar-toggle');
let bootstrapBreakpoint = bp.getBreakpointSize(); let bootstrapBreakpoint = bp.getBreakpointSize();
if (document.querySelector('#js-peek')) initPerformanceBar({ container: '#js-peek' });
initLayoutNav(); initLayoutNav();
// Set the default path for all cookies to GitLab's root directory // Set the default path for all cookies to GitLab's root directory
......
---
title: Add related merge request count to api response
merge_request: 24974
author:
type: added
...@@ -111,6 +111,7 @@ Example response: ...@@ -111,6 +111,7 @@ Example response:
"labels" : [], "labels" : [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"user_notes_count": 1, "user_notes_count": 1,
"due_date": "2016-07-22", "due_date": "2016-07-22",
"web_url": "http://example.com/example/example/issues/6", "web_url": "http://example.com/example/example/issues/6",
...@@ -222,6 +223,7 @@ Example response: ...@@ -222,6 +223,7 @@ Example response:
"labels" : [], "labels" : [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"id" : 41, "id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z", "updated_at" : "2016-01-04T15:31:46.176Z",
...@@ -339,6 +341,7 @@ Example response: ...@@ -339,6 +341,7 @@ Example response:
"labels" : [], "labels" : [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"id" : 41, "id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z", "updated_at" : "2016-01-04T15:31:46.176Z",
...@@ -436,6 +439,7 @@ Example response: ...@@ -436,6 +439,7 @@ Example response:
"labels" : [], "labels" : [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"id" : 41, "id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z", "updated_at" : "2016-01-04T15:31:46.176Z",
...@@ -513,6 +517,7 @@ Example response: ...@@ -513,6 +517,7 @@ Example response:
], ],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"author" : { "author" : {
"name" : "Alexandra Bashirian", "name" : "Alexandra Bashirian",
"avatar_url" : null, "avatar_url" : null,
...@@ -614,6 +619,7 @@ Example response: ...@@ -614,6 +619,7 @@ Example response:
], ],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"id" : 85, "id" : 85,
"assignees" : [], "assignees" : [],
"assignee" : null, "assignee" : null,
...@@ -701,6 +707,7 @@ Example response: ...@@ -701,6 +707,7 @@ Example response:
"labels": [], "labels": [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"milestone": null, "milestone": null,
"assignees": [{ "assignees": [{
"name": "Miss Monserrate Beier", "name": "Miss Monserrate Beier",
...@@ -786,6 +793,7 @@ Example response: ...@@ -786,6 +793,7 @@ Example response:
"labels": [], "labels": [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"milestone": null, "milestone": null,
"assignees": [{ "assignees": [{
"name": "Miss Monserrate Beier", "name": "Miss Monserrate Beier",
...@@ -869,6 +877,7 @@ Example response: ...@@ -869,6 +877,7 @@ Example response:
"labels": [], "labels": [],
"upvotes": 4, "upvotes": 4,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"milestone": null, "milestone": null,
"assignee": { "assignee": {
"name": "Edwardo Grady", "name": "Edwardo Grady",
...@@ -986,6 +995,7 @@ Example response: ...@@ -986,6 +995,7 @@ Example response:
"user_notes_count": 7, "user_notes_count": 7,
"upvotes": 0, "upvotes": 0,
"downvotes": 0, "downvotes": 0,
"merge_requests_count": 0,
"due_date": null, "due_date": null,
"web_url": "http://example.com/example/example/issues/110", "web_url": "http://example.com/example/example/issues/110",
"confidential": false, "confidential": false,
......
...@@ -559,6 +559,15 @@ module API ...@@ -559,6 +559,15 @@ module API
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue| expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
issue issue
end end
expose :merge_requests_count do |issue, options|
if options[:issuable_metadata]
# Avoids an N+1 query when metadata is included
options[:issuable_metadata][issue.id].merge_requests_count
else
issue.merge_requests_closing_issues.count
end
end
end end
class Issue < IssueBasic class Issue < IssueBasic
......
...@@ -425,6 +425,24 @@ describe API::Issues do ...@@ -425,6 +425,24 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/issues') expect(response).to match_response_schema('public_api/v4/issues')
end end
it 'returns a related merge request count of 0 if there are no related merge requests' do
get api('/issues', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/issues')
expect(json_response.first).to include('merge_requests_count' => 0)
end
it 'returns a related merge request count > 0 if there are related merge requests' do
create(:merge_requests_closing_issues, issue: issue)
get api('/issues', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/issues')
expect(json_response.first).to include('merge_requests_count' => 1)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment