FIX: Redirect users to top when `latest` is the homepage
This commit is contained in:
parent
9bf522f227
commit
75488257c5
|
@ -13,6 +13,7 @@ export default Discourse.Route.extend(OpenComposer, {
|
|||
beforeModel(transition) {
|
||||
if (
|
||||
(transition.intent.url === "/" ||
|
||||
transition.intent.url === "/latest" ||
|
||||
transition.intent.url === "/categories") &&
|
||||
transition.targetName.indexOf("discovery.top") === -1 &&
|
||||
Discourse.User.currentProp("should_be_redirected_to_top")
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import { acceptance, logIn, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import DiscoveryFixtures from "fixtures/discovery_fixtures";
|
||||
|
||||
acceptance("Redirect to Top", {
|
||||
pretend(server, helper) {
|
||||
server.get("/top/all.json", () => {
|
||||
return helper.response(DiscoveryFixtures["/latest.json"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function setupUser() {
|
||||
logIn();
|
||||
replaceCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: null,
|
||||
reason: "Welcome back!"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.test("redirects categories to top", async assert => {
|
||||
setupUser();
|
||||
await visit("/categories");
|
||||
assert.equal(currentPath(), "discovery.topAll", "it works for categories");
|
||||
});
|
||||
|
||||
QUnit.test("redirects latest to top", async assert => {
|
||||
setupUser();
|
||||
await visit("/latest");
|
||||
assert.equal(currentPath(), "discovery.topAll", "it works for latest");
|
||||
});
|
||||
|
||||
QUnit.test("redirects root to top", async assert => {
|
||||
setupUser();
|
||||
await visit("/");
|
||||
assert.equal(currentPath(), "discovery.topAll", "it works for root");
|
||||
});
|
|
@ -51,7 +51,7 @@ export default {
|
|||
"posted",
|
||||
"search"
|
||||
],
|
||||
periods: ["yearly", "quarterly", "monthly", "weekly", "daily"],
|
||||
periods: ["all", "yearly", "quarterly", "monthly", "weekly", "daily"],
|
||||
top_menu_items: [
|
||||
"latest",
|
||||
"unread",
|
||||
|
|
|
@ -30,7 +30,7 @@ PreloadStore.store("site", {
|
|||
{ id: 21, name: "test" }
|
||||
],
|
||||
filters: ["latest", "unread", "new", "starred", "read", "posted"],
|
||||
periods: ["yearly", "monthly", "weekly", "daily"],
|
||||
periods: ["all", "yearly", "monthly", "weekly", "daily"],
|
||||
top_menu_items: [
|
||||
"latest",
|
||||
"unread",
|
||||
|
|
Loading…
Reference in New Issue