A platform for community discussion. Free, open, simple.
FIX: When displaying a reviewable, don't append the title to the content (#31851)
Gary Pendergast9d14492f224d
diff --git a/app/serializers/reviewable_score_serializer.rb b/app/serializers/reviewable_score_serializer.rbindex 989456eb2c8..1fe7b888e0e 100644--- a/app/serializers/reviewable_score_serializer.rb+++ b/app/serializers/reviewable_score_serializer.rb@@ -78,10 +78,10 @@ class ReviewableScoreSerializer < ApplicationSerializerif object.context.nil?# If the words weren't recorded, try to guess them based on current settings.if object.reviewable.respond_to?(:post)- s = object.reviewable.post.raw+ s = object.reviewable.post.raw.clones << " #{object.reviewable.post.topic.title}" if object.reviewable.post.post_number == 1elsif object.reviewable.respond_to?(:payload)- s = object.reviewable.payload["raw"]+ s = object.reviewable.payload["raw"].clones << " #{object.reviewable.payload["title"]}" if object.reviewable.payload.key?("title")enddiff --git a/spec/serializers/reviewable_score_serializer_spec.rb b/spec/serializers/reviewable_score_serializer_spec.rbindex 1f6bbc9fe08..3248bc251f5 100644--- a/spec/serializers/reviewable_score_serializer_spec.rb+++ b/spec/serializers/reviewable_score_serializer_spec.rb@@ -69,8 +69,8 @@ RSpec.describe ReviewableScoreSerializer do"<a href=\"#{Discourse.base_url}/admin/customize/watched_words\">#{I18n.t("reviewables.reasons.links.watched_word")}</a>"endit "tries to guess the watched words if they weren't recorded at the time of flagging" do- reviewable.target =- Fabricate(:post, raw: "I'm a post with some bad words like 'bad' and 'words'.")+ raw = "I'm a post with some bad words like 'bad' and 'words'."+ reviewable.target = Fabricate(:post, raw:)score = serialized_score("watched_word")@@ -78,10 +78,13 @@ RSpec.describe ReviewableScoreSerializer doFabricate(:watched_word, action: WatchedWord.actions[:flag], word: "words")expect(score.reason).to include("bad, words")++ expect(reviewable.target.raw).to eq(raw)endit "handles guessing the watched words when the post hasn't been created yet" doqueued_reviewable = Fabricate(:reviewable_queued_post_topic)+ raw = queued_reviewable.payload["raw"].clonereviewable_score =ReviewableScore.new(reviewable: queued_reviewable, reason: "watched_word")@@ -90,6 +93,7 @@ RSpec.describe ReviewableScoreSerializer doresult = described_class.new(reviewable_score, scope: Guardian.new(admin), root: nil)expect(result.reason).to include("contents, title")+ expect(queued_reviewable.payload["raw"]).to eq(raw)endit "uses the no-context message if the post has no watched words" do