mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 01:56:58 +08:00
FEATURE: Promote bookmarks with reminders to core functionality (#9369)
The main thrust of this PR is to take all the conditional checks based on the `enable_bookmarks_with_reminders` away and only keep the code from the `true` path, making bookmarks with reminders the core bookmarks feature. There is also a migration to create `Bookmark` records out of `PostAction` bookmarks for a site. ### Summary * Remove logic based on whether enable_bookmarks_with_reminders is true. This site setting is now obsolete, the old bookmark functionality is being removed. Retain the setting and set the value to `true` in a migration. * Use the code from the rake task to create a database migration that creates bookmarks from post actions. * Change the bookmark report to read from the new table. * Get rid of old endpoints for bookmarks * Link to the new bookmarks list from the user summary page
This commit is contained in:
@ -2346,19 +2346,15 @@ RSpec.describe TopicsController do
|
||||
|
||||
describe '#remove_bookmarks' do
|
||||
it "should remove bookmarks properly from non first post" do
|
||||
bookmark = PostActionType.types[:bookmark]
|
||||
sign_in(user)
|
||||
|
||||
post = create_post
|
||||
post2 = create_post(topic_id: post.topic_id)
|
||||
|
||||
PostActionCreator.new(user, post2, bookmark).perform
|
||||
|
||||
put "/t/#{post.topic_id}/bookmark.json"
|
||||
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(2)
|
||||
Fabricate(:bookmark, user: user, post: post)
|
||||
Fabricate(:bookmark, user: user, post: post2)
|
||||
|
||||
put "/t/#{post.topic_id}/remove_bookmarks.json"
|
||||
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(0)
|
||||
expect(Bookmark.where(user: user).count).to eq(0)
|
||||
end
|
||||
|
||||
it "should disallow bookmarks on posts you have no access to" do
|
||||
@ -2369,10 +2365,7 @@ RSpec.describe TopicsController do
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
context "when SiteSetting.enable_bookmarks_with_reminders is true" do
|
||||
before do
|
||||
SiteSetting.enable_bookmarks_with_reminders = true
|
||||
end
|
||||
context "bookmarks with reminders" do
|
||||
it "deletes all the bookmarks for the user in the topic" do
|
||||
sign_in(user)
|
||||
post = create_post
|
||||
@ -2388,26 +2381,23 @@ RSpec.describe TopicsController do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it "should create a new post action for the bookmark on the first post of the topic" do
|
||||
it "should create a new bookmark on the first post of the topic" do
|
||||
post = create_post
|
||||
post2 = create_post(topic_id: post.topic_id)
|
||||
put "/t/#{post.topic_id}/bookmark.json"
|
||||
|
||||
expect(PostAction.find_by(user_id: user.id, post_action_type: PostActionType.types[:bookmark]).post_id).to eq(post.id)
|
||||
expect(Bookmark.find_by(user_id: user.id).post_id).to eq(post.id)
|
||||
end
|
||||
|
||||
it "errors if the topic is already bookmarked for the user" do
|
||||
post = create_post
|
||||
PostActionCreator.new(user, post, PostActionType.types[:bookmark]).perform
|
||||
Bookmark.create(post: post, user: user, topic: post.topic)
|
||||
|
||||
put "/t/#{post.topic_id}/bookmark.json"
|
||||
expect(response).to be_forbidden
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
|
||||
context "when SiteSetting.enable_bookmarks_with_reminders is true" do
|
||||
before do
|
||||
SiteSetting.enable_bookmarks_with_reminders = true
|
||||
end
|
||||
context "bookmarks with reminders" do
|
||||
it "should create a new bookmark on the first post of the topic" do
|
||||
post = create_post
|
||||
post2 = create_post(topic_id: post.topic_id)
|
||||
|
Reference in New Issue
Block a user