From 9fa384e1dba2c96005470106b1916c568b4264fd Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 23 Nov 2016 10:41:02 -0500 Subject: [PATCH] FIX: In case called during a test --- .../initializers/extend-for-solved-button.js.es6 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 index 83918ae..0dc35d5 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 @@ -145,9 +145,12 @@ function initializeWithApi(api) { api.decorateWidget('post-contents:after-cooked', dec => { if (dec.attrs.post_number === 1) { - const topic = dec.getModel().get('topic'); - if (topic.get('accepted_answer')) { - return dec.rawHtml(`

${topic.get('acceptedAnswerHtml')}

`); + const postModel = dec.getModel(); + if (postModel) { + const topic = postModel.get('topic'); + if (topic.get('accepted_answer')) { + return dec.rawHtml(`

${topic.get('acceptedAnswerHtml')}

`); + } } } });