mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 08:18:42 +08:00
This PR takes the localization features out of "experimental" to prep for the announcement - rename settings and gives them its own area - `experimental_content_localization` to `content_localization_enabled` - `experimental_content_localization_allowed_groups` to `content_localization_allowed_groups` - `experimental_content_localization_supported_locales` to `content_localization_supported_locales` - `experimental_anon_language_switcher` to `content_localization_anon_language_switcher` - migration - related to https://github.com/discourse/discourse-ai/pull/1439 | screenshot 📸 | |---| | <img width="964" alt="Screenshot 2025-06-17 at 5 06 32 PM" src="https://github.com/user-attachments/assets/9a8b2c38-c846-4fc9-8ddd-815c45cc3d0e" /> |
35 lines
1 KiB
Ruby
35 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe BasicPostSerializer do
|
|
describe "#name" do
|
|
fab!(:user)
|
|
fab!(:post) { Fabricate(:post, user: user, cooked: "Hur dur I am a cooked raw") }
|
|
let(:serializer) { BasicPostSerializer.new(post, scope: Guardian.new, root: false) }
|
|
let(:json) { serializer.as_json }
|
|
|
|
it "returns the name it when `enable_names` is true" do
|
|
SiteSetting.enable_names = true
|
|
expect(json[:name]).to be_present
|
|
end
|
|
|
|
it "doesn't return the name it when `enable_names` is false" do
|
|
SiteSetting.enable_names = false
|
|
expect(json[:name]).to be_blank
|
|
end
|
|
|
|
describe "#cooked" do
|
|
it "returns the post's cooked" do
|
|
expect(json[:cooked]).to eq(post.cooked)
|
|
end
|
|
|
|
it "returns the localized cooked" do
|
|
SiteSetting.content_localization_enabled = true
|
|
Fabricate(:post_localization, post: post, cooked: "X", locale: "ja")
|
|
I18n.locale = "ja"
|
|
post.update!(locale: "en")
|
|
|
|
expect(json[:cooked]).to eq("X")
|
|
end
|
|
end
|
|
end
|
|
end
|