mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add "delete on owner reply" bookmark functionality (#10231)
This adds an option to "delete on owner reply" to bookmarks. If you select this option in the modal, then reply to the topic the bookmark is in, the bookmark will be deleted on reply. This PR also changes the checkboxes for these additional bookmark options to an Integer column in the DB with a combobox to select the option you want. The use cases are: * Sometimes I will bookmark the topics to read it later. In this case we definitely don’t need to keep the bookmark after I replied to it. * Sometimes I will read the topic in mobile and I will prefer to reply in PC later. Or I may have to do some research before reply. So I will bookmark it for reply later.
This commit is contained in:
@@ -43,24 +43,13 @@ RSpec.describe BookmarkManager do
|
||||
end
|
||||
|
||||
context "when options are provided" do
|
||||
let(:options) { { delete_when_reminder_sent: true } }
|
||||
let(:options) { { auto_delete_preference: Bookmark.auto_delete_preferences[:when_reminder_sent] } }
|
||||
|
||||
it "saves any additional options successfully" do
|
||||
subject.create(post_id: post.id, name: name, options: options)
|
||||
bookmark = Bookmark.find_by(user: user)
|
||||
|
||||
expect(bookmark.delete_when_reminder_sent).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when options are provided with null values" do
|
||||
let(:options) { { delete_when_reminder_sent: nil } }
|
||||
|
||||
it "saves defaults successfully" do
|
||||
subject.create(post_id: post.id, name: name, options: options)
|
||||
bookmark = Bookmark.find_by(user: user)
|
||||
|
||||
expect(bookmark.delete_when_reminder_sent).to eq(false)
|
||||
expect(bookmark.auto_delete_preference).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -192,12 +181,12 @@ RSpec.describe BookmarkManager do
|
||||
end
|
||||
|
||||
context "when options are provided" do
|
||||
let(:options) { { delete_when_reminder_sent: true } }
|
||||
let(:options) { { auto_delete_preference: Bookmark.auto_delete_preferences[:when_reminder_sent] } }
|
||||
|
||||
it "saves any additional options successfully" do
|
||||
update_bookmark
|
||||
bookmark.reload
|
||||
expect(bookmark.delete_when_reminder_sent).to eq(true)
|
||||
expect(bookmark.auto_delete_preference).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ RSpec.describe BookmarkReminderNotificationHandler do
|
||||
expect(bookmark.reload.no_reminder?).to eq(true)
|
||||
end
|
||||
|
||||
context "when the delete_when_reminder_sent boolean is true " do
|
||||
context "when the auto_delete_preference is when_reminder_sent" do
|
||||
it "deletes the bookmark after the reminder gets sent" do
|
||||
bookmark.update(delete_when_reminder_sent: true)
|
||||
bookmark.update(auto_delete_preference: Bookmark.auto_delete_preferences[:when_reminder_sent])
|
||||
subject.send_notification(bookmark)
|
||||
expect(Bookmark.find_by(id: bookmark.id)).to eq(nil)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user