File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 2323 end
2424
2525 it "truncates to MAX LENGTH" do
26- truncated_text = post . cooked . truncate ( DiscourseTranslator ::DiscourseAi ::MAX_DETECT_LOCALE_TEXT_LENGTH )
27- expect_any_instance_of ( ::DiscourseAi ::AiHelper ::Assistant )
28- . to receive ( :generate_and_send_prompt )
29- . with (
30- CompletionPrompt . find_by ( id : CompletionPrompt ::DETECT_TEXT_LOCALE ) ,
31- truncated_text ,
32- Discourse . system_user
33- ) . and_call_original
26+ truncated_text =
27+ post . cooked . truncate ( DiscourseTranslator ::DiscourseAi ::MAX_DETECT_LOCALE_TEXT_LENGTH )
28+ expect_any_instance_of ( ::DiscourseAi ::AiHelper ::Assistant ) . to receive (
29+ :generate_and_send_prompt ,
30+ ) . with (
31+ CompletionPrompt . find_by ( id : CompletionPrompt ::DETECT_TEXT_LOCALE ) ,
32+ truncated_text ,
33+ Discourse . system_user ,
34+ ) . and_call_original
3435
3536 DiscourseAi ::Completions ::Llm . with_prepared_responses ( [ "<output>de</output>" ] ) do
3637 DiscourseTranslator ::DiscourseAi . detect ( post )
3738 end
3839 end
3940
4041 it "returns if settings are not correct" do
41-
4242 end
4343 end
4444
4545 describe ".translate" do
4646 it "translates the post and returns [locale, translated_text]" do
4747 post = Fabricate ( :post )
48- DiscourseAi ::Completions ::Llm . with_prepared_responses ( [ "<output>some translated text</output>" , "<output>translated</output>" ] ) do
48+ DiscourseAi ::Completions ::Llm . with_prepared_responses (
49+ [ "<output>some translated text</output>" , "<output>translated</output>" ] ,
50+ ) do
4951 locale , translated_text = DiscourseTranslator ::DiscourseAi . translate ( post )
5052 expect ( locale ) . to eq "de"
5153 expect ( translated_text ) . to eq "some translated text"
You can’t perform that action at this time.
0 commit comments