|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +describe Jobs::PostTranslationBackfill do |
| 4 | + before do |
| 5 | + SiteSetting.automatic_translation_backfill_rate = 100 |
| 6 | + SiteSetting.automatic_translation_target_languages = "en" |
| 7 | + end |
| 8 | + |
| 9 | + it "does not enqueue post translation when translator disabled" do |
| 10 | + SiteSetting.translator_enabled = false |
| 11 | + |
| 12 | + described_class.new.execute({}) |
| 13 | + |
| 14 | + expect_not_enqueued_with(job: :translate_posts) |
| 15 | + end |
| 16 | + |
| 17 | + it "does not enqueue post translation when experimental translation disabled" do |
| 18 | + SiteSetting.translator_enabled = true |
| 19 | + SiteSetting.experimental_content_translation = false |
| 20 | + |
| 21 | + described_class.new.execute({}) |
| 22 | + |
| 23 | + expect_not_enqueued_with(job: :translate_posts) |
| 24 | + end |
| 25 | + |
| 26 | + it "does not enqueue psot translation if backfill languages are not set" do |
| 27 | + SiteSetting.translator_enabled = true |
| 28 | + SiteSetting.experimental_content_translation = true |
| 29 | + SiteSetting.automatic_translation_target_languages = "" |
| 30 | + |
| 31 | + described_class.new.execute({}) |
| 32 | + |
| 33 | + expect_not_enqueued_with(job: :translate_posts) |
| 34 | + end |
| 35 | + |
| 36 | + it "does not enqueue psot translation if backfill limit is set to 0" do |
| 37 | + SiteSetting.translator_enabled = true |
| 38 | + SiteSetting.experimental_content_translation = true |
| 39 | + SiteSetting.automatic_translation_backfill_rate = 0 |
| 40 | + |
| 41 | + described_class.new.execute({}) |
| 42 | + |
| 43 | + expect_not_enqueued_with(job: :translate_posts) |
| 44 | + end |
| 45 | + |
| 46 | + it "enqueues post translation with correct limit" do |
| 47 | + SiteSetting.translator_enabled = true |
| 48 | + SiteSetting.experimental_content_translation = true |
| 49 | + SiteSetting.automatic_translation_backfill_rate = 10 |
| 50 | + |
| 51 | + described_class.new.execute({}) |
| 52 | + |
| 53 | + expect_job_enqueued(job: :translate_posts, args: { limit: 10 }) |
| 54 | + end |
| 55 | +end |
0 commit comments