FIX: 500 error when reviewable has a missing message (#25113)
This commit is contained in:
parent
0546b4622a
commit
117611ea82
|
@ -40,7 +40,8 @@ module Chat
|
|||
|
||||
def build_actions(actions, guardian, args)
|
||||
return unless pending?
|
||||
return if chat_message.blank?
|
||||
|
||||
return build_action(actions, :ignore, icon: "external-link-alt") if chat_message.blank?
|
||||
|
||||
agree =
|
||||
actions.add_bundle(
|
||||
|
|
|
@ -15,7 +15,7 @@ module Chat
|
|||
end
|
||||
|
||||
def chat_channel
|
||||
object.chat_message.chat_channel
|
||||
object.chat_message&.chat_channel
|
||||
end
|
||||
|
||||
def target_id
|
||||
|
|
|
@ -17,22 +17,27 @@ export default class ReviewableChatMessage extends Component {
|
|||
|
||||
@cached
|
||||
get channel() {
|
||||
if (!this.args.reviewable.chat_channel) {
|
||||
return;
|
||||
}
|
||||
return ChatChannel.create(this.args.reviewable.chat_channel);
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="flagged-post-header">
|
||||
<LinkTo
|
||||
@route="chat.channel.near-message"
|
||||
@models={{array
|
||||
this.channel.slugifiedTitle
|
||||
this.channel.id
|
||||
@reviewable.target_id
|
||||
}}
|
||||
>
|
||||
<ChannelTitle @channel={{this.channel}} />
|
||||
</LinkTo>
|
||||
</div>
|
||||
{{#if this.channel}}
|
||||
<div class="flagged-post-header">
|
||||
<LinkTo
|
||||
@route="chat.channel.near-message"
|
||||
@models={{array
|
||||
this.channel.slugifiedTitle
|
||||
this.channel.id
|
||||
@reviewable.target_id
|
||||
}}
|
||||
>
|
||||
<ChannelTitle @channel={{this.channel}} />
|
||||
</LinkTo>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="post-contents-wrapper">
|
||||
<ReviewableCreatedBy
|
||||
|
|
|
@ -24,4 +24,20 @@ describe "Reviewables", type: :system do
|
|||
expect(page).to have_content(message_1.message)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the message is hard deleted" do
|
||||
before { message_1.destroy! }
|
||||
|
||||
it "does not throw an error" do
|
||||
visit("/review?type=Chat%3A%3AReviewableMessage")
|
||||
|
||||
expect(page).to have_selector(".reviewable-item.reviewable-chat-message")
|
||||
end
|
||||
|
||||
it "adds the option to ignore the flag" do
|
||||
visit("/review?type=Chat%3A%3AReviewableMessage")
|
||||
|
||||
expect(page).to have_selector(".reviewable-actions .chat-message-ignore")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue