Skip to content

A platform for community discussion. Free, open, simple.

FIX: default channel name to topic title (#33754)

Joffrey JAFFEUX39686e646425
diff --git a/plugins/discourse-calendar/app/services/discourse_post_event/chat_channel_sync.rb b/plugins/discourse-calendar/app/services/discourse_post_event/chat_channel_sync.rb
index 37f9320a66f..b981f39b41e 100644
--- a/plugins/discourse-calendar/app/services/discourse_post_event/chat_channel_sync.rb
+++ b/plugins/discourse-calendar/app/services/discourse_post_event/chat_channel_sync.rb
@@ -48,7 +48,7 @@ module DiscoursePostEvent
end
def self.ensure_chat_channel!(event, guardian:)
- name = event.name
+ name = event.name || event.post.topic.title
channel = nil
Chat::CreateCategoryChannel.call(
diff --git a/plugins/discourse-calendar/spec/services/discourse_post_event/chat_channel_sync_spec.rb b/plugins/discourse-calendar/spec/services/discourse_post_event/chat_channel_sync_spec.rb
index 5af48f70466..2879e23c94d 100644
--- a/plugins/discourse-calendar/spec/services/discourse_post_event/chat_channel_sync_spec.rb
+++ b/plugins/discourse-calendar/spec/services/discourse_post_event/chat_channel_sync_spec.rb
@@ -8,7 +8,7 @@ describe DiscoursePostEvent::ChatChannelSync do
fab!(:admin_post) { Fabricate(:post, user: admin) }
it "is able to create a chat channel and sync members" do
- event = Fabricate(:event, chat_enabled: true, post: admin_post)
+ event = Fabricate(:event, chat_enabled: true, post: admin_post, name: "Test Event")
expect(event.chat_channel_id).to be_present
expect(event.chat_channel.name).to eq(event.name)
@@ -27,4 +27,10 @@ describe DiscoursePostEvent::ChatChannelSync do
expect(event.chat_channel_id).to be_nil
end
+
+ it "defaults event name to post title" do
+ event = Fabricate(:event, chat_enabled: true, post: admin_post)
+
+ expect(event.chat_channel.name).to eq(admin_post.topic.title)
+ end
end