DEV: Change Bookmarkable registration to DiscoursePluginRegistry (#20556)

Similar spirit to e195e6f614,
this moves the Bookmarkable registration to DiscoursePluginRegistry
so plugins which are not enabled do not register additional
bookmarkable classes.
This commit is contained in:
Martin Brennan
2023-03-08 10:39:12 +10:00
committed by GitHub
parent 1c881c1037
commit 360d0dde65
16 changed files with 43 additions and 46 deletions

View File

@@ -280,7 +280,6 @@ after_initialize do
Category.prepend Chat::CategoryExtension
User.prepend Chat::UserExtension
Jobs::UserEmail.prepend Chat::UserEmailExtension
Bookmark.register_bookmarkable(ChatMessageBookmarkable)
end
if Oneboxer.respond_to?(:register_local_handler)
@@ -777,6 +776,8 @@ after_initialize do
register_user_destroyer_on_content_deletion_callback(
Proc.new { |user| Jobs.enqueue(:delete_user_messages, user_id: user.id) },
)
register_bookmarkable(ChatMessageBookmarkable)
end
if Rails.env == "test"

View File

@@ -11,10 +11,12 @@ describe ChatMessageBookmarkable do
fab!(:channel) { Fabricate(:category_channel) }
before do
Bookmark.register_bookmarkable(ChatMessageBookmarkable)
register_test_bookmarkable(ChatMessageBookmarkable)
UserChatChannelMembership.create(chat_channel: channel, user: user, following: true)
end
after { DiscoursePluginRegistry.reset! }
let!(:message1) { Fabricate(:chat_message, chat_channel: channel) }
let!(:message2) { Fabricate(:chat_message, chat_channel: channel) }
let!(:bookmark1) do

View File

@@ -499,8 +499,6 @@ describe ChatMessage do
end
describe "bookmarks" do
before { Bookmark.register_bookmarkable(ChatMessageBookmarkable) }
it "destroys bookmarks" do
message_1 = Fabricate(:chat_message)
bookmark_1 = Fabricate(:bookmark, bookmarkable: message_1)

View File

@@ -18,9 +18,6 @@ module ChatSystemHelpers
end
Group.refresh_automatic_groups!
# this is reset after each test
Bookmark.register_bookmarkable(ChatMessageBookmarkable)
end
def chat_thread_chain_bootstrap(channel:, users:, messages_count: 4)