FEATURE: Polymorphic bookmarks pt. 1 (CRUD) (#16308)

This commit introduces a new use_polymorphic_bookmarks site setting
that is default false and hidden, that will be used to help continuous
development of polymorphic bookmarks. This setting **should not** be
enabled anywhere in production yet, it is purely for local development.

This commit uses the setting to enable create/update/delete actions
for polymorphic bookmarks on the server and client side. The bookmark
interactions on topics/posts are all usable. Listing, searching,
sending bookmark reminders, and other edge cases will be handled
in subsequent PRs.

Comprehensive UI tests will be added in the final PR -- we already
have them for regular bookmarks, so it will just be a matter of
changing them to be for polymorphic bookmarks.
This commit is contained in:
Martin Brennan
2022-03-30 12:43:11 +10:00
committed by GitHub
parent ff93833fdf
commit b8828d4a2d
27 changed files with 711 additions and 127 deletions

View File

@ -394,17 +394,21 @@ RSpec.describe TopicView do
end
end
context "#user_post_bookmarks" do
context "#bookmarks" do
let!(:user) { Fabricate(:user) }
let!(:bookmark1) { Fabricate(:bookmark, post: Fabricate(:post, topic: topic), user: user) }
let!(:bookmark2) { Fabricate(:bookmark, post: Fabricate(:post, topic: topic), user: user) }
let!(:bookmark3) { Fabricate(:bookmark, post: Fabricate(:post, topic: topic)) }
it "returns all the bookmarks in the topic for a user" do
expect(TopicView.new(topic.id, user).user_post_bookmarks.pluck(:id)).to match_array(
expect(TopicView.new(topic.id, user).bookmarks.pluck(:id)).to match_array(
[bookmark1.id, bookmark2.id]
)
end
it "returns [] for anon users" do
expect(TopicView.new(topic.id, nil).bookmarks.pluck(:id)).to eq([])
end
end
context "#bookmarks" do