File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
app/services/discourse_translator Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -79,8 +79,9 @@ def self.strip_tags_for_detection(detection_text)
7979 end
8080
8181 def self . text_for_detection ( topic_or_post )
82- strip_tags_for_detection (
83- get_text ( topic_or_post ) . truncate ( DETECTION_CHAR_LIMIT , omission : nil ) ,
82+ strip_tags_for_detection ( get_text ( topic_or_post ) ) . truncate (
83+ DETECTION_CHAR_LIMIT ,
84+ omission : nil ,
8485 )
8586 end
8687
Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ class EmptyTranslator < DiscourseTranslator::Base
8282 post . cooked = text
8383 expect ( DiscourseTranslator ::Base . text_for_detection ( post ) ) . to eq ( text )
8484 end
85+
86+ it "strips text before truncation" do
87+ post . cooked = "<img src='http://example.com/image.png' />" + "a" * 1000
88+ expect ( DiscourseTranslator ::Base . text_for_detection ( post ) ) . to eq ( "a" * 1000 )
89+ end
8590 end
8691
8792 describe ".text_for_translation" do
You can’t perform that action at this time.
0 commit comments