mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 20:35:21 +08:00
68c4f16a73
The settings tab of each category channel should now present the option to allow or disallow channel wide mentions: @here and @all. When disallowed, using these mentions in the channel should have no effect.
51 lines
1.6 KiB
Ruby
51 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
describe ChatChannelSerializer do
|
|
fab!(:user) { Fabricate(:user) }
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
|
let(:guardian_user) { user }
|
|
let(:guardian) { Guardian.new(guardian_user) }
|
|
subject { described_class.new(chat_channel, scope: guardian, root: nil) }
|
|
|
|
describe "archive status" do
|
|
context "when user is not staff" do
|
|
let(:guardian_user) { user }
|
|
|
|
it "does not return any sort of archive status" do
|
|
expect(subject.as_json.key?(:archive_completed)).to eq(false)
|
|
end
|
|
|
|
it "includes allow_channel_wide_mentions" do
|
|
expect(subject.as_json.key?(:allow_channel_wide_mentions)).to eq(true)
|
|
end
|
|
end
|
|
|
|
context "when user is staff" do
|
|
let(:guardian_user) { admin }
|
|
|
|
it "includes the archive status if the channel is archived and the archive record exists" do
|
|
expect(subject.as_json.key?(:archive_completed)).to eq(false)
|
|
|
|
chat_channel.update!(status: ChatChannel.statuses[:archived])
|
|
expect(subject.as_json.key?(:archive_completed)).to eq(false)
|
|
|
|
ChatChannelArchive.create!(
|
|
chat_channel: chat_channel,
|
|
archived_by: admin,
|
|
destination_topic_title: "This will be the archive topic",
|
|
total_messages: 10,
|
|
)
|
|
chat_channel.reload
|
|
expect(subject.as_json.key?(:archive_completed)).to eq(true)
|
|
end
|
|
|
|
it "includes allow_channel_wide_mentions" do
|
|
expect(subject.as_json.key?(:allow_channel_wide_mentions)).to eq(true)
|
|
end
|
|
end
|
|
end
|
|
end
|