From ef3faff8f1d9988b4d4b42e3b1e9e43bbab1899e Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@omgsrsly.net>
Date: Mon, 13 Feb 2017 21:47:14 +0100
Subject: [PATCH] Render mentions as links in comments

---
 app/assets/javascripts/app/views/comment_view.js |  2 +-
 app/presenters/comment_presenter.rb              | 11 ++++++-----
 features/desktop/mentions.feature                | 12 ++++++++++++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/app/assets/javascripts/app/views/comment_view.js b/app/assets/javascripts/app/views/comment_view.js
index 7f74d1146a..6ca7a4355d 100644
--- a/app/assets/javascripts/app/views/comment_view.js
+++ b/app/assets/javascripts/app/views/comment_view.js
@@ -20,7 +20,7 @@ app.views.Comment = app.views.Content.extend({
   presenter : function() {
     return _.extend(this.defaultPresenter(), {
       canRemove: this.canRemove(),
-      text : app.helpers.textFormatter(this.model.get("text"))
+      text: app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people"))
     });
   },
 
diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb
index 95eef095cb..f687ba7b87 100644
--- a/app/presenters/comment_presenter.rb
+++ b/app/presenters/comment_presenter.rb
@@ -5,11 +5,12 @@ class CommentPresenter < BasePresenter
 
   def as_json(opts={})
     {
-      :id => @comment.id,
-      :guid => @comment.guid,
-      :text  => @comment.message.plain_text_for_json,
-      :author => @comment.author.as_api_response(:backbone),
-      :created_at => @comment.created_at
+      id:               @comment.id,
+      guid:             @comment.guid,
+      text:             @comment.message.plain_text_for_json,
+      author:           @comment.author.as_api_response(:backbone),
+      created_at:       @comment.created_at,
+      mentioned_people: @comment.mentioned_people.as_api_response(:backbone)
     }
   end
 end
diff --git a/features/desktop/mentions.feature b/features/desktop/mentions.feature
index 01791180f0..000e1f963c 100644
--- a/features/desktop/mentions.feature
+++ b/features/desktop/mentions.feature
@@ -54,3 +54,15 @@ Feature: Mentions
     Then I should see "Bob Jones" within ".stream-element"
     When I follow "Bob Jones"
     Then I should see "Bob Jones"
+
+  Scenario: A user mentions another user in a comment and it displays correctly
+    Given following users exist:
+      | username     | email             |
+      | Bob Jones    | bob@bob.bob       |
+      | Alice Smith  | alice@alice.alice |
+    And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
+    And "alice@alice.alice" has a public post with text "check this out!"
+    And "alice@alice.alice" has commented mentioning "bob@bob.bob" on "check this out!"
+    When I sign in as "alice@alice.alice"
+    And I follow "Bob Jones"
+    Then I should see "Bob Jones"
-- 
GitLab