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)
|
def build_actions(actions, guardian, args)
|
||||||
return unless pending?
|
return unless pending?
|
||||||
return if chat_message.blank?
|
|
||||||
|
return build_action(actions, :ignore, icon: "external-link-alt") if chat_message.blank?
|
||||||
|
|
||||||
agree =
|
agree =
|
||||||
actions.add_bundle(
|
actions.add_bundle(
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Chat
|
||||||
end
|
end
|
||||||
|
|
||||||
def chat_channel
|
def chat_channel
|
||||||
object.chat_message.chat_channel
|
object.chat_message&.chat_channel
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_id
|
def target_id
|
||||||
|
|
|
@ -17,10 +17,14 @@ export default class ReviewableChatMessage extends Component {
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
get channel() {
|
get channel() {
|
||||||
|
if (!this.args.reviewable.chat_channel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return ChatChannel.create(this.args.reviewable.chat_channel);
|
return ChatChannel.create(this.args.reviewable.chat_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
{{#if this.channel}}
|
||||||
<div class="flagged-post-header">
|
<div class="flagged-post-header">
|
||||||
<LinkTo
|
<LinkTo
|
||||||
@route="chat.channel.near-message"
|
@route="chat.channel.near-message"
|
||||||
|
@ -33,6 +37,7 @@ export default class ReviewableChatMessage extends Component {
|
||||||
<ChannelTitle @channel={{this.channel}} />
|
<ChannelTitle @channel={{this.channel}} />
|
||||||
</LinkTo>
|
</LinkTo>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<div class="post-contents-wrapper">
|
<div class="post-contents-wrapper">
|
||||||
<ReviewableCreatedBy
|
<ReviewableCreatedBy
|
||||||
|
|
|
@ -24,4 +24,20 @@ describe "Reviewables", type: :system do
|
||||||
expect(page).to have_content(message_1.message)
|
expect(page).to have_content(message_1.message)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue