From 27fab2ef9dac3fe44397f404fc4c948a3a4d19ca Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 28 Feb 2017 11:04:56 +0000 Subject: [PATCH] Clone nested objects from default data. Checks if key is present before accessing it Fix broken test --- .../cycle_analytics/cycle_analytics_store.js.es6 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6 b/app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6 index 3efeb141008..7ae9de7297c 100644 --- a/app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6 +++ b/app/assets/javascripts/cycle_analytics/cycle_analytics_store.js.es6 @@ -75,8 +75,11 @@ const DEFAULT_EVENT_OBJECTS = require('./default_event_objects'); const eventItem = Object.assign({}, DEFAULT_EVENT_OBJECTS[stage.slug], item); eventItem.totalTime = eventItem.total_time; - eventItem.author.webUrl = eventItem.author.web_url; - eventItem.author.avatarUrl = eventItem.author.avatar_url; + + if (eventItem.author) { + eventItem.author.webUrl = eventItem.author.web_url; + eventItem.author.avatarUrl = eventItem.author.avatar_url; + } if (eventItem.created_at) eventItem.createdAt = eventItem.created_at; if (eventItem.short_sha) eventItem.shortSha = eventItem.short_sha;