mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 05:23:37 +08:00
4fdb275683
Some of the changes in this commit are extracted from https://github.com/discourse/discourse/pull/17379. The bookmarks tab in the new user menu is different from the other tabs in that it can display a mixture of notifications and bookmarks. When there are unread bookmark reminder notifications, the tab displays all of these notifications at the top and fills the remaining space in the menu with the rest of the bookmarks. The bubble/badge count on the bookmarks tab indicates how many unread bookmark reminder notifications there are. On the technical aspect, since this commit introduces a new `bookmark-item` component, we've done some refactoring so that all 3 "item" components (`notification-item`, `reviewable-item` and the new `bookmark-item`) inherit from a base component and get identical HTML structure so they all look consistent. Internal tickets: t70584 and t65045.
33 lines
1020 B
Ruby
33 lines
1020 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UserPostBookmarkSerializer do
|
|
let(:user) { Fabricate(:user) }
|
|
let(:topic) { Fabricate(:topic) }
|
|
let(:post) { Fabricate(:post, user: user, topic: topic) }
|
|
let!(:bookmark) { Fabricate(:bookmark, name: 'Test', user: user, bookmarkable: post) }
|
|
|
|
describe "#highest_post_number" do
|
|
let(:whisperers_group) { Fabricate(:group) }
|
|
|
|
before do
|
|
SiteSetting.enable_whispers = true
|
|
SiteSetting.whispers_allowed_groups = "#{whisperers_group.id}"
|
|
end
|
|
|
|
it "uses the correct highest_post_number column based on whether the user is whisperer" do
|
|
Fabricate(:post, topic: topic)
|
|
Fabricate(:post, topic: topic)
|
|
Fabricate(:whisper, topic: topic)
|
|
topic.reload
|
|
bookmark.reload
|
|
serializer = UserPostBookmarkSerializer.new(bookmark, scope: Guardian.new(user))
|
|
|
|
expect(serializer.highest_post_number).to eq(3)
|
|
|
|
user.groups << whisperers_group
|
|
|
|
expect(serializer.highest_post_number).to eq(4)
|
|
end
|
|
end
|
|
end
|