Fixes spec failures due to not returning metrics for MRs other than closed/merged

This commit is contained in:
Oswaldo Ferreira 2018-01-02 19:27:00 -02:00
parent bf8c20729b
commit feee48a4cf
3 changed files with 9 additions and 2 deletions

View file

@ -125,6 +125,10 @@ export default class MergeRequestStore {
}
static buildMetrics(metrics) {
if (!metrics) {
return {};
}
return {
mergedBy: MergeRequestStore.formatUserObject(metrics.merged_by),
closedBy: MergeRequestStore.formatUserObject(metrics.closed_by),

View file

@ -32,8 +32,10 @@
"target_branch": { "type": "string" },
"target_project_id": { "type": "integer" },
"metrics": {
"type": "object",
"$ref": "merge_request_metrics.json"
"oneOf": [
{ "type": "null" },
{ "$ref": "merge_request_metrics.json" }
]
},
"author": { "type": ["object", "null"] },
"merge_user": { "type": ["object", "null"] },

View file

@ -72,6 +72,7 @@ describe MergeRequestWidgetEntity do
context 'when metrics does not exists' do
before do
resource.mark_as_merged!
resource.metrics.destroy!
resource.reload
end