mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 16:43:40 +08:00
09932738e5
Before, whispers were only available for staff members. Config has been changed to allow to configure privileged groups with access to whispers. Post migration was added to move from the old setting into the new one. I considered having a boolean column `whisperer` on user model similar to `admin/moderator` for performance reason. Finally, I decided to keep looking for groups as queries are only done for current user and didn't notice any N+1 queries.
30 lines
944 B
Ruby
30 lines
944 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UserPostBookmarkSerializer do
|
|
let(:whisperers_group) { Fabricate(:group) }
|
|
let(:user) { Fabricate(:user) }
|
|
let(:post) { Fabricate(:post, user: user, topic: topic) }
|
|
let(:topic) { Fabricate(:topic) }
|
|
let!(:bookmark) { Fabricate(:bookmark, name: 'Test', user: user, bookmarkable: post) }
|
|
|
|
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
|