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

This commit is contained in:
Guo Xiang Tan 2019-01-16 15:55:18 +08:00
parent 27e2b6575b
commit f8db93df5f
4 changed files with 27 additions and 4 deletions

View File

@ -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
}`
);
}

View File

@ -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);
});
}
});

View File

@ -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 => {

View File

@ -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: {