Skip to content

Commit 3087235

Browse files
committed
Update test
1 parent 989de07 commit 3087235

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lib/discourse_translator/dual_text_translation.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ def inject(plugin)
88
# as automatic translations send content for language detection as a side effect of translating
99

1010
plugin.on(:post_process_cooked) do |_, post|
11-
if SiteSetting.automatic_translation_target_languages.nil? &&
11+
if SiteSetting.automatic_translation_target_languages.blank? &&
1212
Guardian.new.can_detect_language?(post) && post.user_id > 0
1313
Jobs.enqueue(:detect_translatable_language, type: "Post", translatable_id: post.id)
1414
end
1515
end
1616

1717
plugin.on(:topic_created) do |topic|
18-
if SiteSetting.automatic_translation_target_languages.nil? && topic.user_id > 0
19-
Jobs.enqueue(:detect_translatable_language, type: "Topic", translatable_id: post.id)
18+
if SiteSetting.automatic_translation_target_languages.blank? && topic.user_id > 0
19+
Jobs.enqueue(:detect_translatable_language, type: "Topic", translatable_id: topic.id)
2020
end
2121
end
2222
end

spec/models/post_spec.rb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,19 @@
7373
fab!(:topic)
7474
fab!(:user) { Fabricate(:user, groups: [group]) }
7575

76-
before { Jobs.run_immediately! }
77-
7876
it "queues the post for language detection when user and posts are in the right group" do
7977
SiteSetting.restrict_translation_by_poster_group = "#{group.id}"
80-
post =
81-
PostCreator.new(
82-
user,
83-
{
84-
title: "a topic about cats",
85-
raw: "tomtom is a cat",
86-
category: Fabricate(:category).id,
87-
},
88-
).create
8978

90-
expect(
91-
Discourse.redis.sismember(DiscourseTranslator::LANG_DETECT_NEEDED, post.id),
92-
).to be_truthy
79+
post = Fabricate(:post, user: user)
80+
CookedPostProcessor.new(post).post_process
81+
82+
expect_job_enqueued(
83+
job: :detect_translatable_language,
84+
args: {
85+
type: "Post",
86+
translatable_id: post.id,
87+
},
88+
)
9389
end
9490

9591
it "does not queue bot posts for language detection" do

0 commit comments

Comments
 (0)