discourse/spec/lib/post_localization_destroyer_spec.rb
Natalie Tay 38e6420016
FEATURE: Also process manually updated translations (#35276)
This is a follow up to
https://github.com/discourse/discourse/pull/34900.

When a user manually updates translation via the translation composer,
also send the new translated cooked for post processing. I moved the
Processor to core, given PostLocalizations are core feature.

<img width="551" height="385" alt="Screenshot 2025-10-08 at 6 12 26 PM"
src="https://github.com/user-attachments/assets/1cce7ce3-5487-4e75-90fd-440792b9a899"
/>
2025-10-09 00:33:36 +08:00

40 lines
1.2 KiB
Ruby

# frozen_string_literal: true
describe PostLocalizationDestroyer do
fab!(:user)
fab!(:post)
fab!(:group)
fab!(:localization) { Fabricate(:post_localization, post:, locale: "ja") }
let(:locale) { "ja" }
before do
SiteSetting.content_localization_enabled = true
SiteSetting.content_localization_allowed_groups = group.id.to_s
group.add(user)
end
it "deletes the localization" do
expect {
described_class.destroy(post_id: post.id, locale: locale, acting_user: user)
}.to change { PostLocalization.count }.by(-1)
expect { PostLocalization.find(localization.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
it "raises not found if the localization is missing" do
expect {
described_class.destroy(post_id: post.id, locale: "nope", acting_user: user)
}.to raise_error(Discourse::NotFound)
end
it "publishes MessageBus notification" do
messages =
MessageBus.track_publish("/topic/#{post.topic_id}") do
described_class.destroy(post_id: post.id, locale: locale, acting_user: user)
end
expect(messages.length).to eq(1)
expect(messages.first.data[:type]).to eq(:revised)
expect(messages.first.data[:id]).to eq(post.id)
end
end