mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 12:49:23 +08:00
Related: - https://github.com/discourse/discourse-translator/pull/205 - https://github.com/discourse/discourse-translator/pull/274 - https://github.com/discourse/discourse-translator/pull/294 With this PR, we will start showing localized posts (if available) based on the user's locale. This work had been done in discourse-translator, but is now moving to core.
24 lines
708 B
Ruby
Vendored
24 lines
708 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe BasicTopicSerializer do
|
|
fab!(:topic) { Fabricate(:topic, title: "Hur dur this is a title") }
|
|
|
|
describe "#fancy_title" do
|
|
it "returns the fancy title" do
|
|
json = BasicTopicSerializer.new(topic).as_json
|
|
|
|
expect(json[:basic_topic][:fancy_title]).to eq(topic.title)
|
|
end
|
|
|
|
it "returns the fancy title with a modifier" do
|
|
SiteSetting.experimental_content_localization = true
|
|
Fabricate(:topic_localization, topic:, fancy_title: "X", locale: "ja")
|
|
I18n.locale = "ja"
|
|
topic.update!(locale: "en")
|
|
|
|
json = BasicTopicSerializer.new(topic).as_json
|
|
|
|
expect(json[:basic_topic][:fancy_title]).to eq("X")
|
|
end
|
|
end
|
|
end
|