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,22 +17,27 @@ 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>
|
||||||
<div class="flagged-post-header">
|
{{#if this.channel}}
|
||||||
<LinkTo
|
<div class="flagged-post-header">
|
||||||
@route="chat.channel.near-message"
|
<LinkTo
|
||||||
@models={{array
|
@route="chat.channel.near-message"
|
||||||
this.channel.slugifiedTitle
|
@models={{array
|
||||||
this.channel.id
|
this.channel.slugifiedTitle
|
||||||
@reviewable.target_id
|
this.channel.id
|
||||||
}}
|
@reviewable.target_id
|
||||||
>
|
}}
|
||||||
<ChannelTitle @channel={{this.channel}} />
|
>
|
||||||
</LinkTo>
|
<ChannelTitle @channel={{this.channel}} />
|
||||||
</div>
|
</LinkTo>
|
||||||
|
</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