2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-17 18:04:11 +08:00

FIX: Also update topic locale on creation (#33544)

When a user creates a new topic via the composer and sets the locale, we
currently set the post's locale but not the topic's. This PR updates
that.
This commit is contained in:
Natalie Tay 2025-07-10 00:33:20 +08:00 committed by GitHub
parent 6e7947949f
commit 12d433dfca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -134,7 +134,7 @@ class TopicCreator
visible: @opts[:visible],
}
%i[subtype archetype import_mode advance_draft].each do |key|
%i[subtype archetype import_mode advance_draft locale].each do |key|
topic_params[key] = @opts[key] if @opts[key].present?
end

View file

@ -91,6 +91,18 @@ RSpec.describe TopicCreator do
)
expect(topic.participant_count).to eq(3)
end
describe "locale" do
it "updates the locale of the topic" do
topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(locale: "ja"))
expect(topic.locale).to eq("ja")
end
it "sets the locale of the topic to nil if blank" do
topic1 = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(locale: ""))
expect(topic1.locale).to eq(nil)
end
end
end
end