mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 13:35:20 -05:00
FEATURE: MVP Bookmarks with reminders user list changes (#8999)
* This PR changes the user activity bookmarks stream to show a new list of bookmarks based on the Bookmark record. * If a bookmark has a name or reminder it will be shown as metadata above the topic title in the list * The categories, tags, topic status, and assigned show for each bookmarked post based on the post topic * Bookmarks can be deleted from the [...] menu in the list * As well as this, the list of bookmarks from the quick access panel is now drawn from the Bookmarks table for a user: * All of this new functionality is gated behind the enable_bookmarks_with_reminders site setting The /bookmarks/ route now redirects directly to /user/:username/activity/bookmarks-with-reminders * The structure of the Ember for the list of bookmarks is not ideal, this is an MVP PR so we can start testing this functionality internally. There is a little repeated code from topic.js.es6. There is an ongoing effort to start standardizing these lists that will be addressed in future PRs. * This PR also fixes issues with feature detection for at_desktop bookmark reminders
This commit is contained in:
@@ -10,31 +10,36 @@ RSpec.describe BookmarkReminderNotificationHandler do
|
||||
before do
|
||||
SiteSetting.enable_bookmarks_with_reminders = true
|
||||
end
|
||||
fab!(:reminder) do
|
||||
Fabricate(
|
||||
:bookmark,
|
||||
user: user,
|
||||
reminder_type: Bookmark.reminder_types[:at_desktop],
|
||||
reminder_at: nil,
|
||||
reminder_set_at: Time.zone.now
|
||||
)
|
||||
end
|
||||
let(:user_agent) { "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36" }
|
||||
|
||||
context "when the user agent is for mobile" do
|
||||
let(:user_agent) { "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" }
|
||||
it "does not attempt to send any reminders" do
|
||||
DistributedMutex.expects(:synchronize).never
|
||||
send_reminder
|
||||
end
|
||||
before do
|
||||
Discourse.redis.flushall
|
||||
end
|
||||
|
||||
context "when the user agent is for desktop" do
|
||||
let(:user_agent) { "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36" }
|
||||
fab!(:reminder) do
|
||||
Fabricate(
|
||||
:bookmark,
|
||||
user: user,
|
||||
reminder_type: Bookmark.reminder_types[:at_desktop],
|
||||
reminder_at: nil,
|
||||
reminder_set_at: Time.zone.now
|
||||
)
|
||||
context "when there are pending bookmark at desktop reminders" do
|
||||
before do
|
||||
described_class.cache_pending_at_desktop_reminder(user)
|
||||
end
|
||||
|
||||
context "when there are pending bookmark at desktop reminders" do
|
||||
before do
|
||||
described_class.cache_pending_at_desktop_reminder(user)
|
||||
context "when the user agent is for mobile" do
|
||||
let(:user_agent) { "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" }
|
||||
it "does not attempt to send any reminders" do
|
||||
DistributedMutex.expects(:synchronize).never
|
||||
send_reminder
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user agent is for desktop" do
|
||||
let(:user_agent) { "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36" }
|
||||
|
||||
it "deletes the key in redis" do
|
||||
send_reminder
|
||||
@@ -49,23 +54,23 @@ RSpec.describe BookmarkReminderNotificationHandler do
|
||||
expect(reminder.reload.reminder_set_at).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when there are no pending bookmark at desktop reminders" do
|
||||
it "does nothing" do
|
||||
DistributedMutex.expects(:synchronize).never
|
||||
send_reminder
|
||||
end
|
||||
context "when there are no pending bookmark at desktop reminders" do
|
||||
it "does nothing" do
|
||||
DistributedMutex.expects(:synchronize).never
|
||||
send_reminder
|
||||
end
|
||||
end
|
||||
|
||||
context "when enable bookmarks with reminders is disabled" do
|
||||
before do
|
||||
SiteSetting.enable_bookmarks_with_reminders = false
|
||||
end
|
||||
|
||||
context "when enable bookmarks with reminders is disabled" do
|
||||
before do
|
||||
SiteSetting.enable_bookmarks_with_reminders = false
|
||||
end
|
||||
|
||||
it "does nothing" do
|
||||
BrowserDetection.expects(:device).never
|
||||
send_reminder
|
||||
end
|
||||
it "does nothing" do
|
||||
BrowserDetection.expects(:device).never
|
||||
send_reminder
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user