FIX: Consolidated like notifications links to wrong user on user page.

FIX: Consolidated like notifications links to wrong user on user page.

diff --git a/app/assets/javascripts/discourse/widgets/notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
index bd43d2d..93e1315 100644
--- a/app/assets/javascripts/discourse/widgets/notification-item.js.es6
+++ b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
@@ -64,9 +64,11 @@ createWidget("notification-item", {
 
     if (attrs.notification_type === LIKED_CONSOLIDATED_TYPE) {
       return userPath(
-        `${
-          this.currentUser.username
-        }/notifications/likes-received?acting_username=${data.display_username}`
+        `${this.attrs.username ||
+          this.currentUser
+            .username}/notifications/likes-received?acting_username=${
+          data.display_username
+        }`
       );
     }
 
diff --git a/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6 b/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
index d8a8c69..11e8753 100644
--- a/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
+++ b/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
@@ -22,6 +22,11 @@ createWidget("large-notification-item", {
 export default createWidget("user-notifications-large", {
   html(attrs) {
     const notifications = attrs.notifications;
-    return notifications.map(n => this.attach("large-notification-item", n));
+    const username = notifications.findArgs.username;
+
+    return notifications.map(n => {
+      n.username = username;
+      return this.attach("large-notification-item", n);
+    });
   }
 });
diff --git a/test/javascripts/acceptance/user-test.js.es6 b/test/javascripts/acceptance/user-test.js.es6
index 8a05a93..253f126 100644
--- a/test/javascripts/acceptance/user-test.js.es6
+++ b/test/javascripts/acceptance/user-test.js.es6
@@ -15,6 +15,16 @@ QUnit.test("Messages", async assert => {
 QUnit.test("Notifications", async assert => {
   await visit("/u/eviltrout/notifications");
   assert.ok($("body.user-notifications-page").length, "has the body class");
+
+  await visit("/u/test/notifications");
+
+  const $links = find(".item.notification a");
+
+  assert.ok(
+    $links[1].href.includes(
+      "/u/test/notifications/likes-received?acting_username=aquaman"
+    )
+  );
 });
 
 QUnit.test("Root URL - Viewing Self", async assert => {
diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6
index 02f84ca..d4e34d5 100644
--- a/test/javascripts/helpers/create-pretender.js.es6
+++ b/test/javascripts/helpers/create-pretender.js.es6
@@ -79,6 +79,12 @@ export default function() {
       return response(json);
     });
 
+    this.get("/u/test.json", () => {
+      const json = fixturesByUrl["/u/eviltrout.json"];
+      json.user.username = "test";
+      return response(json);
+    });
+
     this.get("/u/eviltrout/summary.json", () => {
       return response({
         user_summary: {

GitHub sha: f8db93df

1 Like