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
|
||||
object.user || Chat::NullUser.new
|
||||
end
|
||||
|
||||
def excerpt
|
||||
object.excerpt || object.build_excerpt
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,5 +30,10 @@ RSpec.describe Chat::InReplyToSerializer do
|
|||
it "censors words" do
|
||||
expect(serializer.as_json[:excerpt]).to eq("ok ■■■■■")
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue