From f09e6316366d9588c06b2c0266016fa4f178e73c Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 29 Feb 2024 09:11:40 +1000 Subject: [PATCH] DEV: Adapt to core bookmark changes (#280) * Added can_see_bookmarkable? methods to BaseBookmarkable, implement that in QueryGroupBookmarkable * Update spec to check that Notification for reminder has bookmarkable_id and bookmarkable_type c.f. https://github.com/discourse/discourse/pull/25905 --- .discourse-compatibility | 1 + lib/discourse_data_explorer/query_group_bookmarkable.rb | 8 ++++++-- spec/lib/data_explorer/query_group_bookmarkable_spec.rb | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.discourse-compatibility b/.discourse-compatibility index f5ffcaf..db923a7 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 3.3.0.beta1-dev: ebe71a7a138c856d88737eb11b5096a42d4fbaf3 < 3.2.0.beta4-dev: 9f841a4c6f45b4a5bf81e2b9a6f389acf69cd13c 3.1.999: e4f8d3924a18b303c2bb7da9472cf0c060060e4e 3.1.0.beta4: 2cc87a10157852112712b7df1f7135b71023ad92 diff --git a/lib/discourse_data_explorer/query_group_bookmarkable.rb b/lib/discourse_data_explorer/query_group_bookmarkable.rb index 4d2cf33..b63d86f 100644 --- a/lib/discourse_data_explorer/query_group_bookmarkable.rb +++ b/lib/discourse_data_explorer/query_group_bookmarkable.rb @@ -55,8 +55,12 @@ module ::DiscourseDataExplorer end def self.can_see?(guardian, bookmark) - return false if !bookmark.bookmarkable.group - guardian.user_is_a_member_of_group?(bookmark.bookmarkable.group) + can_see_bookmarkable?(guardian, bookmark.bookmarkable) + end + + def self.can_see_bookmarkable?(guardian, bookmarkable) + return false if !bookmarkable.group + guardian.user_is_a_member_of_group?(bookmarkable.group) end end end diff --git a/spec/lib/data_explorer/query_group_bookmarkable_spec.rb b/spec/lib/data_explorer/query_group_bookmarkable_spec.rb index adaa80c..12ff78e 100644 --- a/spec/lib/data_explorer/query_group_bookmarkable_spec.rb +++ b/spec/lib/data_explorer/query_group_bookmarkable_spec.rb @@ -141,7 +141,7 @@ describe DiscourseDataExplorer::QueryGroupBookmarkable do end describe "#reminder_handler" do - xit "creates a notification for the user with the correct details" do + it "creates a notification for the user with the correct details" do expect { registered_bookmarkable.send_reminder_notification(bookmark1) }.to change { Notification.count }.by(1) @@ -155,6 +155,8 @@ describe DiscourseDataExplorer::QueryGroupBookmarkable do display_username: bookmark1.user.username, bookmark_name: bookmark1.name, bookmark_id: bookmark1.id, + bookmarkable_type: bookmark1.bookmarkable_type, + bookmarkable_id: bookmark1.bookmarkable_id, }.to_json, ) end