discourse/spec/jobs/check_translation_overrides_spec.rb
Ted Johansson 70eaa976a5
DEV: Refresh translation override status when updating (#31233)
Translation overrides can be marked as "invalid interpolation keys" or "outdated" if the original translation is changed. We run a job every hour to check for this. We also have an admin problem check for it.

The problem is we don't refresh this status when an admin updates the override. So even if the invalid keys are removed, the override will still show up under the "invalid" filter.

There's a similar situation with the "outdated" status. The admin is shown a prompt which they can dismiss, which in turn updates the status, but updating the translation should also count as "addressing" it.

This PR runs a refresh on the override status when updating.
2025-02-07 14:12:28 +08:00

40 lines
1.4 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Jobs::CheckTranslationOverrides do
fab!(:up_to_date_translation) { Fabricate(:translation_override, translation_key: "title") }
fab!(:deprecated_translation) do
allow_missing_translations { Fabricate(:translation_override, translation_key: "foo.bar") }
end
fab!(:outdated_translation) do
Fabricate(:translation_override, translation_key: "posts", original_translation: "outdated")
end
fab!(:invalid_translation) { Fabricate(:translation_override, translation_key: "topics") }
it "marks translations with keys which no longer exist in the locale file" do
expect { described_class.new.execute({}) }.to change {
deprecated_translation.reload.status
}.from("up_to_date").to("deprecated")
end
it "marks translations with invalid interpolation keys" do
expect do
invalid_translation.update_attribute("value", "Invalid %{foo}")
described_class.new.execute({})
end.to change { invalid_translation.reload.status }.from("up_to_date").to(
"invalid_interpolation_keys",
)
end
it "marks translations that are outdated" do
expect { described_class.new.execute({}) }.to change {
outdated_translation.reload.status
}.from("up_to_date").to("outdated")
end
it "does not mark up to date translations" do
expect { described_class.new.execute({}) }.not_to change {
up_to_date_translation.reload.status
}
end
end