DEV: correct a relationship – a chat message may have several mentions (#20219)

This change only makes the model reflect correctly what's 
already happening in the database. Note that there are no calls 
to chat_message.chat_mention in Core and plugins so this 
change should be safe.

Also note, that at the moment we use the chat_mentions db 
table only to support notifications about mentions, but 
we're going to start using it for other cases. This commit is 
the first step in that direction.
This commit is contained in:
Andrei Prigorshnev 2023-02-09 17:44:04 +04:00 committed by GitHub
parent 45412206f7
commit 0dcfd7ddec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -22,7 +22,7 @@ class ChatMessage < ActiveRecord::Base
# TODO (martin) Remove this when we drop the ChatUpload table
has_many :chat_uploads, dependent: :destroy
has_one :chat_webhook_event, dependent: :destroy
has_one :chat_mention, dependent: :destroy
has_many :chat_mentions, dependent: :destroy
scope :in_public_channel,
-> {

View File

@ -5,6 +5,8 @@ require "rails_helper"
describe ChatMessage do
fab!(:message) { Fabricate(:chat_message, message: "hey friend, what's up?!") }
it { is_expected.to have_many(:chat_mentions).dependent(:destroy) }
describe ".cook" do
it "does not support HTML tags" do
cooked = ChatMessage.cook("<h1>test</h1>")