mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:39:36 +08:00
b80765f1f4
* DEV: Remove enable_whispers site setting Whispers are enabled as long as there is at least one group allowed to whisper, see whispers_allowed_groups site setting. * DEV: Always enable whispers for admins if at least one group is allowed.
32 lines
979 B
Ruby
32 lines
979 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.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
|