mirror of
https://ghfast.top/https://github.com/discourse/discourse-translator.git
synced 2026-07-16 11:46:33 +08:00
Currently, only posts are being translated. When a post is the first post, we should include information about the topic. Meta https://meta.discourse.org/t/feature-request-topic-title-translation/144714
32 lines
881 B
Ruby
32 lines
881 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
RSpec.describe Topic do
|
|
describe "translator custom fields" do
|
|
fab!(:topic) do
|
|
Fabricate(
|
|
:topic,
|
|
title: "this is a sample title",
|
|
custom_fields: {
|
|
::DiscourseTranslator::DETECTED_LANG_CUSTOM_FIELD => "en",
|
|
::DiscourseTranslator::TRANSLATED_CUSTOM_FIELD => {
|
|
"en" => "lol",
|
|
},
|
|
},
|
|
)
|
|
end
|
|
|
|
before { SiteSetting.translator_enabled = true }
|
|
|
|
after { SiteSetting.translator_enabled = false }
|
|
|
|
it "should reset custom fields when topic title has been updated" do
|
|
topic.update!(title: "this is an updated title")
|
|
|
|
expect(topic.custom_fields[::DiscourseTranslator::DETECTED_LANG_CUSTOM_FIELD]).to be_nil
|
|
|
|
expect(topic.custom_fields[::DiscourseTranslator::TRANSLATED_CUSTOM_FIELD]).to be_nil
|
|
end
|
|
end
|
|
end
|