mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FEATURE: allows to enable/disable threading in UI (#22307)
Enabling/Disabling threading has been possible through command line until now. This commit introduces two new UIs: - When creating a channel, it will be available once the category has been selected - On the settings page of a channel for admins
This commit is contained in:
@ -629,6 +629,7 @@ RSpec.describe Chat::Api::ChannelsController do
|
||||
chatable_id: category.id,
|
||||
name: "channel name",
|
||||
description: "My new channel",
|
||||
threading_enabled: false,
|
||||
},
|
||||
}
|
||||
end
|
||||
@ -691,6 +692,25 @@ RSpec.describe Chat::Api::ChannelsController do
|
||||
expect(new_channel.auto_join_users).to eq(true)
|
||||
end
|
||||
|
||||
it "creates a channel sets threading_enabled to false by default" do
|
||||
post "/chat/api/channels", params: params
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
new_channel = Chat::Channel.find(response.parsed_body.dig("channel", "id"))
|
||||
|
||||
expect(new_channel.threading_enabled).to eq(false)
|
||||
end
|
||||
|
||||
it "creates a channel with threading_enabled set to true" do
|
||||
params[:channel][:threading_enabled] = true
|
||||
post "/chat/api/channels", params: params
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
new_channel = Chat::Channel.find(response.parsed_body.dig("channel", "id"))
|
||||
|
||||
expect(new_channel.threading_enabled).to eq(true)
|
||||
end
|
||||
|
||||
describe "triggers the auto-join process" do
|
||||
fab!(:chatters_group) { Fabricate(:group) }
|
||||
fab!(:user) { Fabricate(:user, last_seen_at: 15.minute.ago) }
|
||||
@ -884,6 +904,18 @@ RSpec.describe Chat::Api::ChannelsController do
|
||||
expect(response.parsed_body["channel"]).to match_response_schema("category_chat_channel")
|
||||
end
|
||||
|
||||
describe "when updating threading_enabled" do
|
||||
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
|
||||
|
||||
it "sets the new value" do
|
||||
expect {
|
||||
put "/chat/api/channels/#{channel.id}", params: { channel: { threading_enabled: true } }
|
||||
}.to change { channel.reload.threading_enabled }.from(false).to(true)
|
||||
|
||||
expect(response.parsed_body["channel"]["threading_enabled"]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when updating allow_channel_wide_mentions" do
|
||||
it "sets the new value" do
|
||||
put "/chat/api/channels/#{channel.id}",
|
||||
|
Reference in New Issue
Block a user