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
This commit is contained in:
Martin Brennan 2024-02-29 09:11:40 +10:00 committed by GitHub
parent 94e29e2143
commit f09e631636
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,4 @@
< 3.3.0.beta1-dev: ebe71a7a138c856d88737eb11b5096a42d4fbaf3
< 3.2.0.beta4-dev: 9f841a4c6f45b4a5bf81e2b9a6f389acf69cd13c < 3.2.0.beta4-dev: 9f841a4c6f45b4a5bf81e2b9a6f389acf69cd13c
3.1.999: e4f8d3924a18b303c2bb7da9472cf0c060060e4e 3.1.999: e4f8d3924a18b303c2bb7da9472cf0c060060e4e
3.1.0.beta4: 2cc87a10157852112712b7df1f7135b71023ad92 3.1.0.beta4: 2cc87a10157852112712b7df1f7135b71023ad92

View File

@ -55,8 +55,12 @@ module ::DiscourseDataExplorer
end end
def self.can_see?(guardian, bookmark) def self.can_see?(guardian, bookmark)
return false if !bookmark.bookmarkable.group can_see_bookmarkable?(guardian, bookmark.bookmarkable)
guardian.user_is_a_member_of_group?(bookmark.bookmarkable.group) 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 end
end end

View File

@ -141,7 +141,7 @@ describe DiscourseDataExplorer::QueryGroupBookmarkable do
end end
describe "#reminder_handler" do 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 { expect { registered_bookmarkable.send_reminder_notification(bookmark1) }.to change {
Notification.count Notification.count
}.by(1) }.by(1)
@ -155,6 +155,8 @@ describe DiscourseDataExplorer::QueryGroupBookmarkable do
display_username: bookmark1.user.username, display_username: bookmark1.user.username,
bookmark_name: bookmark1.name, bookmark_name: bookmark1.name,
bookmark_id: bookmark1.id, bookmark_id: bookmark1.id,
bookmarkable_type: bookmark1.bookmarkable_type,
bookmarkable_id: bookmark1.bookmarkable_id,
}.to_json, }.to_json,
) )
end end