Commit feee48a4 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

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

parent bf8c2072
...@@ -125,6 +125,10 @@ export default class MergeRequestStore { ...@@ -125,6 +125,10 @@ export default class MergeRequestStore {
} }
static buildMetrics(metrics) { static buildMetrics(metrics) {
if (!metrics) {
return {};
}
return { return {
mergedBy: MergeRequestStore.formatUserObject(metrics.merged_by), mergedBy: MergeRequestStore.formatUserObject(metrics.merged_by),
closedBy: MergeRequestStore.formatUserObject(metrics.closed_by), closedBy: MergeRequestStore.formatUserObject(metrics.closed_by),
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
"target_branch": { "type": "string" }, "target_branch": { "type": "string" },
"target_project_id": { "type": "integer" }, "target_project_id": { "type": "integer" },
"metrics": { "metrics": {
"type": "object", "oneOf": [
"$ref": "merge_request_metrics.json" { "type": "null" },
{ "$ref": "merge_request_metrics.json" }
]
}, },
"author": { "type": ["object", "null"] }, "author": { "type": ["object", "null"] },
"merge_user": { "type": ["object", "null"] }, "merge_user": { "type": ["object", "null"] },
......
...@@ -72,6 +72,7 @@ describe MergeRequestWidgetEntity do ...@@ -72,6 +72,7 @@ describe MergeRequestWidgetEntity do
context 'when metrics does not exists' do context 'when metrics does not exists' do
before do before do
resource.mark_as_merged!
resource.metrics.destroy! resource.metrics.destroy!
resource.reload resource.reload
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