mirror of
https://github.com/discourse/discourse.git
synced 2025-04-10 12:40:49 +08:00
FIX: add excerpt fallback for chat message replies (#26834)
This commit is contained in:
parent
acdaa3b579
commit
c1f6ec5f62
@ -10,5 +10,9 @@ module Chat
|
|||||||
def user
|
def user
|
||||||
object.user || Chat::NullUser.new
|
object.user || Chat::NullUser.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def excerpt
|
||||||
|
object.excerpt || object.build_excerpt
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,5 +30,10 @@ RSpec.describe Chat::InReplyToSerializer do
|
|||||||
it "censors words" do
|
it "censors words" do
|
||||||
expect(serializer.as_json[:excerpt]).to eq("ok ■■■■■")
|
expect(serializer.as_json[:excerpt]).to eq("ok ■■■■■")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "builds an excerpt for replied to message if it doesn’t have one" do
|
||||||
|
message.update!(excerpt: nil)
|
||||||
|
expect(serializer.as_json[:excerpt]).to eq(message.build_excerpt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user