FIX: redirect to top was always redirecting to 'All'
This commit is contained in:
@@ -3,14 +3,51 @@ import DiscoveryFixtures from "fixtures/discovery_fixtures";
|
||||
|
||||
acceptance("Redirect to Top", {
|
||||
pretend(server, helper) {
|
||||
server.get("/top/weekly.json", () => {
|
||||
return helper.response(DiscoveryFixtures["/latest.json"]);
|
||||
});
|
||||
server.get("/top/monthly.json", () => {
|
||||
return helper.response(DiscoveryFixtures["/latest.json"]);
|
||||
});
|
||||
server.get("/top/all.json", () => {
|
||||
return helper.response(DiscoveryFixtures["/latest.json"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function setupUser() {
|
||||
QUnit.test("redirects categories to weekly top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: "weekly",
|
||||
reason: "Welcome back!"
|
||||
}
|
||||
});
|
||||
|
||||
await visit("/categories");
|
||||
assert.equal(currentPath(), "discovery.topWeekly", "it works for categories");
|
||||
});
|
||||
|
||||
QUnit.test("redirects latest to monthly top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: "monthly",
|
||||
reason: "Welcome back!"
|
||||
}
|
||||
});
|
||||
|
||||
await visit("/latest");
|
||||
assert.equal(currentPath(), "discovery.topMonthly", "it works for latest");
|
||||
});
|
||||
|
||||
QUnit.test("redirects root to All top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
@@ -18,22 +55,7 @@ function setupUser() {
|
||||
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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user