FEATURE: add user opt to select bookmarks as home (#10597)

FEATURE: add user opt to select bookmarks as home (#10597)

Admins can currently add the bookmarks discovery route link to the homepage interface, but users can’t presently select that as their default home view. This change facilitates that, adding the option to the existing Default Home Page dropdown on the User Preferences Interface page.

diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
index 1f80751..54137cb 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
@@ -25,6 +25,7 @@ const USER_HOMES = {
   3: "unread",
   4: "new",
   5: "top",
+  6: "bookmarks",
 };
 
 const TEXT_SIZES = ["smallest", "smaller", "normal", "larger", "largest"];
diff --git a/app/models/user_option.rb b/app/models/user_option.rb
index 74cab6d..1c0cfbb 100644
--- a/app/models/user_option.rb
+++ b/app/models/user_option.rb
@@ -163,6 +163,7 @@ class UserOption < ActiveRecord::Base
     when 3 then "unread"
     when 4 then "new"
     when 5 then "top"
+    when 6 then "bookmarks"
     else SiteSetting.homepage
     end
   end
diff --git a/test/javascripts/acceptance/preferences-test.js b/test/javascripts/acceptance/preferences-test.js
index 0cb6b92..ba256f7 100644
--- a/test/javascripts/acceptance/preferences-test.js
+++ b/test/javascripts/acceptance/preferences-test.js
@@ -427,3 +427,33 @@ QUnit.test("can select an option from a dropdown", async (assert) => {
   await field.selectRowByValue("Cat");
   assert.equal(field.header().value(), "Cat", "it sets the value of the field");
 });
+
+acceptance(
+  "User Preferences, selecting bookmarks discovery as user's default homepage",
+  {
+    loggedIn: true,
+    settings: {
+      top_menu: "categories|latest|top|bookmarks",
+    },
+  }
+);
+
+QUnit.test(
+  "selecting bookmarks as home directs home to bookmarks",
+  async (assert) => {
+    await visit("/u/eviltrout/preferences/interface");
+    assert.ok(exists(".home .combo-box"), "it has a home selector combo-box");
+
+    const field = selectKit(".home .combo-box");
+    await field.expand();
+    await field.selectRowByValue("6");
+    await click(".save-changes");
+    await visit("/");
+    assert.ok(exists(".topic-list"), "The list of topics was rendered");
+    assert.equal(
+      currentPath(),
+      "discovery.bookmarks",
+      "it navigates to bookmarks"
+    );
+  }
+);
diff --git a/test/javascripts/fixtures/discovery_fixtures.js b/test/javascripts/fixtures/discovery_fixtures.js
index 9e09ab9..1a15885 100644
--- a/test/javascripts/fixtures/discovery_fixtures.js
+++ b/test/javascripts/fixtures/discovery_fixtures.js
@@ -1143,6 +1143,250 @@ export default {
       ]
     }
   },
+  "/bookmarks.json": {
+    users: [
+      { id: 7204, username: "reyman64", avatar_template: "/images/avatar.png" },
+      { id: 1, username: "sam", avatar_template: "/images/avatar.png" },
+      { id: 5481, username: "f0rkz", avatar_template: "/images/avatar.png" },
+      { id: 6473, username: "jkf", avatar_template: "/images/avatar.png" },
+      {
+        id: 6973,
+        username: "stellarhopper",
+        avatar_template: "/images/avatar.png"
+      },
+      {
+        id: 19,
+        username: "eviltrout",
+        name: "Evil Trout",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 14, username: "clay", avatar_template: "/images/avatar.png" },
+      {
+        id: 32,
+        username: "codinghorror",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 1917, username: "sil", avatar_template: "/images/avatar.png" },
+      { id: 7197, username: "peeja", avatar_template: "/images/avatar.png" },
+      { id: 1995, username: "zogstrip", avatar_template: "/images/avatar.png" },
+      {
+        id: 8021,
+        username: "Abhishek_Gupta",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 2291, username: "PabloC", avatar_template: "/images/avatar.png" },
+      { id: 791, username: "srid", avatar_template: "/images/avatar.png" },
+      {
+        id: 1580,
+        username: "ABillionSuns",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 7270, username: "mhurwi", avatar_template: "/images/avatar.png" },
+      {
+        id: 6695,
+        username: "illspirit",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 6929, username: "BCHK", avatar_template: "/images/avatar.png" },
+      { id: 4385, username: "jeans", avatar_template: "/images/avatar.png" },
+      { id: 7073, username: "5an1ty", avatar_template: "/images/avatar.png" },
+      { id: 6626, username: "riking", avatar_template: "/images/avatar.png" },
+      { id: 4457, username: "Lee_Ars", avatar_template: "/images/avatar.png" },
+      { id: 4263, username: "mcwumbly", avatar_template: "/images/avatar.png" },
+      {
+        id: 8134,
+        username: "iontishina",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 2072, username: "nXqd", avatar_template: "/images/avatar.png" },
+      {
+        id: 4983,
+        username: "hey_julien",
+        avatar_template: "/images/avatar.png"
+      },
+      {
+        id: 3657,
+        username: "steelmaiden",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 2624, username: "BowlingX", avatar_template: "/images/avatar.png" },
+      {
+        id: 8085,
+        username: "watchmanmonitor",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 4612, username: "Iszi", avatar_template: "/images/avatar.png" },
+      {
+        id: 8018,
+        username: "shivermetimbers",
+        avatar_template: "/images/avatar.png"
+      },
+      {
+        id: 6060,
+        username: "lightyear",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 2, username: "neil", avatar_template: "/images/avatar.png" },
+      { id: 8037, username: "printec", avatar_template: "/images/avatar.png" },
+      { id: 3415, username: "radq", avatar_template: "/images/avatar.png" },
+      {
+        id: 6283,
+        username: "hrishikesh",
+        avatar_template: "/images/avatar.png"
+      },
+      {
+        id: 471,
+        username: "BhaelOchon",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 6548, username: "michaeld", avatar_template: "/images/avatar.png" },
+      {
+        id: 7286,
+        username: "mrotsnahoj",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 3169, username: "dgw", avatar_template: "/images/avatar.png" },
+      {
+        id: 926,
+        username: "martinnormark",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 2003, username: "taylor", avatar_template: "/images/avatar.png" },
+      { id: 369, username: "CvX", avatar_template: "/images/avatar.png" },
+      { id: 562, username: "nightpool", avatar_template: "/images/avatar.png" },
+      { id: 6653, username: "amitfrid", avatar_template: "/images/avatar.png" },
+      {
+        id: 6677,
+        username: "Tropnevad",
+        avatar_template: "/images/avatar.png"
+      },
+      {
+        id: 5048,
+        username: "SneakySly",
+        avatar_template: "/images/avatar.png"
+      },
+      { id: 7333, username: "Jong", avatar_template: "/images/avatar.png" },
+      { id: 3124, username: "sipp11", avatar_template: "/images/avatar.png" },
+      { id: 7604, username: "citkane", avatar_template: "/images/avatar.png" },
+      { id: 3929, username: "ScotterC", avatar_template: "/images/avatar.png" },
+      { id: 6680, username: "cdman", avatar_template: "/images/avatar.png" },
+      { id: 500, username: "aeid", avatar_template: "/images/avatar.png" },
+      { id: 8, username: "geek", avatar_template: "/images/avatar.png" },
+      { id: 606, username: "Cafeine", avatar_template: "/images/avatar.png" }
+    ],
+    topic_list: {
+      can_create_topic: false,
+      more_topics_url: "/bookmarks.json?page=1",
+      draft: null,
+      draft_key: "new_topic",
+      draft_sequence: null,
+      topics: [
+        {
+          id: 11557,
+          title: "Error after upgrade to 0.9.7.9+",
+          fancy_title: "Error after upgrade to 0.9.7.9+",

[... diff too long, it was truncated ...]

GitHub sha: dee45160

This commit appears in #10597 which was approved by eviltrout. It was merged by eviltrout.