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() {
initUserPopovers();
if (document.querySelector('.search')) initSearchAutocomplete();
if (document.querySelector('#js-peek')) initPerformanceBar({ container: '#js-peek' });
addSelectOnFocusBehaviour('.js-select-on-focus');
......@@ -148,6 +147,8 @@ document.addEventListener('DOMContentLoaded', () => {
const $sidebarGutterToggle = $('.js-sidebar-toggle');
let bootstrapBreakpoint = bp.getBreakpointSize();
if (document.querySelector('#js-peek')) initPerformanceBar({ container: '#js-peek' });
initLayoutNav();
// 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:
"labels" : [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"user_notes_count": 1,
"due_date": "2016-07-22",
"web_url": "http://example.com/example/example/issues/6",
......@@ -222,6 +223,7 @@ Example response:
"labels" : [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
......@@ -339,6 +341,7 @@ Example response:
"labels" : [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
......@@ -436,6 +439,7 @@ Example response:
"labels" : [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
......@@ -513,6 +517,7 @@ Example response:
],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"author" : {
"name" : "Alexandra Bashirian",
"avatar_url" : null,
......@@ -614,6 +619,7 @@ Example response:
],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"id" : 85,
"assignees" : [],
"assignee" : null,
......@@ -701,6 +707,7 @@ Example response:
"labels": [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"milestone": null,
"assignees": [{
"name": "Miss Monserrate Beier",
......@@ -786,6 +793,7 @@ Example response:
"labels": [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"milestone": null,
"assignees": [{
"name": "Miss Monserrate Beier",
......@@ -869,6 +877,7 @@ Example response:
"labels": [],
"upvotes": 4,
"downvotes": 0,
"merge_requests_count": 0,
"milestone": null,
"assignee": {
"name": "Edwardo Grady",
......@@ -986,6 +995,7 @@ Example response:
"user_notes_count": 7,
"upvotes": 0,
"downvotes": 0,
"merge_requests_count": 0,
"due_date": null,
"web_url": "http://example.com/example/example/issues/110",
"confidential": false,
......
......@@ -559,6 +559,15 @@ module API
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
issue
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
class Issue < IssueBasic
......
......@@ -425,6 +425,24 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/issues')
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
......
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