FIX: Safely return from missing post on check_dont_feed_the_trolls (#21238)

This commit is contained in:
Isaac Janzen 2023-04-25 10:08:00 -05:00 committed by GitHub
parent 4e0c07c56d
commit 96700d55a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -233,7 +233,7 @@ class ComposerMessagesFinder
if @details[:post_id]
Post.find_by(id: @details[:post_id])
else
@topic.first_post
@topic&.first_post
end
return if post.blank?

View File

@ -395,6 +395,11 @@ RSpec.describe ComposerMessagesFinder do
)
expect(finder.check_dont_feed_the_trolls).to be_present
end
it "safely returns from not finding a post" do
finder = ComposerMessagesFinder.new(user, composer_action: "reply", topic_id: nil)
expect(finder.check_dont_feed_the_trolls).to be_blank
end
end
describe ".check_get_a_room" do