mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 13:18:14 +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" /> |
43 lines
1.2 KiB
Ruby
43 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe PostLocalizationUpdater do
|
|
fab!(:user)
|
|
fab!(:post) { Fabricate(:post, version: 99) }
|
|
fab!(:group)
|
|
fab!(:post_localization) do
|
|
Fabricate(:post_localization, post: post, locale: "ja", raw: "古いバージョン")
|
|
end
|
|
|
|
let(:locale) { "ja" }
|
|
let(:new_raw) { "新しいバージョンです" }
|
|
|
|
before do
|
|
SiteSetting.content_localization_enabled = true
|
|
SiteSetting.content_localization_allowed_groups = group.id.to_s
|
|
group.add(user)
|
|
end
|
|
|
|
it "updates an existing localization" do
|
|
localization =
|
|
described_class.update(post_id: post.id, locale: locale, raw: new_raw, user: user)
|
|
|
|
expect(localization).to have_attributes(
|
|
raw: new_raw,
|
|
cooked: PrettyText.cook(new_raw),
|
|
localizer_user_id: user.id,
|
|
post_version: post.version,
|
|
)
|
|
end
|
|
|
|
it "raises not found if the localization is missing" do
|
|
expect {
|
|
described_class.update(post_id: post.id, locale: "nope", raw: new_raw, user: user)
|
|
}.to raise_error(Discourse::NotFound)
|
|
end
|
|
|
|
it "raises not found if the post is missing" do
|
|
expect {
|
|
described_class.update(post_id: -1, locale: locale, raw: new_raw, user: user)
|
|
}.to raise_error(Discourse::NotFound)
|
|
end
|
|
end
|