mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:03:43 +08:00
FIX: replace fullPath
while rewriting the /my/
URLs.
And added the tests. Follow-up to cdca5a2ee4
This commit is contained in:
parent
0c8365a1a2
commit
aa017f276f
|
@ -247,7 +247,7 @@ const DiscourseURL = EmberObject.extend({
|
|||
if (fullPath.indexOf(myPath) === 0) {
|
||||
const currentUser = User.current();
|
||||
if (currentUser) {
|
||||
path = path.replace(
|
||||
path = fullPath.replace(
|
||||
myPath,
|
||||
userPath(currentUser.get("username_lower"))
|
||||
);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import DiscourseURL, { userPath } from "discourse/lib/url";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import { logIn } from "helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
QUnit.module("lib:url");
|
||||
|
||||
|
@ -66,3 +68,16 @@ QUnit.test("userPath with prefix", assert => {
|
|||
assert.equal(userPath("eviltrout"), "/forum/u/eviltrout");
|
||||
assert.equal(userPath("hp.json"), "/forum/u/hp.json");
|
||||
});
|
||||
|
||||
QUnit.test("routeTo with prefix", async assert => {
|
||||
setPrefix("/forum");
|
||||
logIn();
|
||||
const user = User.current();
|
||||
|
||||
sandbox.stub(DiscourseURL, "handleURL");
|
||||
DiscourseURL.routeTo("/my/messages");
|
||||
assert.ok(
|
||||
DiscourseURL.handleURL.calledWith(`/u/${user.username}/messages`),
|
||||
"it should navigate to the messages page"
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user