Fix milestones disappearing when changed on MR

This commit is contained in:
Mario de la Ossa 2018-06-14 13:39:17 -06:00
parent edfa2e3fb6
commit c6420ce2ab
No known key found for this signature in database
GPG Key ID: 20CA8F4C6A20761B
5 changed files with 23 additions and 6 deletions

View File

@ -16,10 +16,10 @@ export default class MilestoneSelect {
typeof currentProject === 'string' ? JSON.parse(currentProject) : currentProject;
}
this.init(els, options);
MilestoneSelect.init(els, options);
}
init(els, options) {
static init(els, options) {
let $els = $(els);
if (!els) {
@ -224,7 +224,6 @@ export default class MilestoneSelect {
$selectBox.hide();
$value.css('display', '');
if (data.milestone != null) {
data.milestone.full_path = this.currentProject.full_path;
data.milestone.remaining = timeFor(data.milestone.due_date);
data.milestone.name = data.milestone.title;
$value.html(milestoneLinkTemplate(data.milestone));

View File

@ -115,7 +115,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
format.json do
render json: @merge_request.to_json(include: { milestone: {}, assignee: { only: [:name, :username], methods: [:avatar_url] }, labels: { methods: :text_color } }, methods: [:task_status, :task_status_short])
render json: serializer.represent(@merge_request, serializer: 'basic')
end
end
rescue ActiveRecord::StaleObjectError

View File

@ -5,4 +5,8 @@ class MergeRequestBasicEntity < IssuableSidebarEntity
expose :state
expose :source_branch_exists?, as: :source_branch_exists
expose :rebase_in_progress?, as: :rebase_in_progress
expose :milestone, using: API::Entities::Milestone
expose :labels, using: LabelEntity
expose :assignee, using: API::Entities::UserBasic
expose :task_status, :task_status_short
end

View File

@ -234,7 +234,7 @@ describe Projects::MergeRequestsController do
body = JSON.parse(response.body)
expect(body['assignee'].keys)
.to match_array(%w(name username avatar_url))
.to match_array(%w(name username avatar_url id state web_url))
end
end

View File

@ -14,7 +14,21 @@
"subscribed": { "type": ["boolean", "null"] },
"participants": { "type": "array" },
"allow_collaboration": { "type": "boolean"},
"allow_maintainer_to_push": { "type": "boolean"}
"allow_maintainer_to_push": { "type": "boolean"},
"assignee": {
"oneOf": [
{ "type": "null" },
{ "$ref": "user.json" }
]
},
"milestone": {
"type": [ "object", "null" ]
},
"labels": {
"type": [ "array", "null" ]
},
"task_status": { "type": "string" },
"task_status_short": { "type": "string" }
},
"additionalProperties": false
}