FIX: Ensure auto close notice is posted with system locale

Previously it was created with the locale of the user who created the final post in the topic
This commit is contained in:
David Taylor 2020-08-17 15:40:47 +01:00
parent c164e9bbe0
commit 0a5376084d
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 24 additions and 2 deletions

View File

@ -351,7 +351,8 @@ class PostCreator
:closed, true, Discourse.system_user,
message: I18n.t(
'topic_statuses.autoclosed_message_max_posts',
count: SiteSetting.auto_close_messages_post_count
count: SiteSetting.auto_close_messages_post_count,
locale: SiteSetting.default_locale
)
)
elsif !is_private_message &&
@ -363,7 +364,8 @@ class PostCreator
:closed, true, Discourse.system_user,
message: I18n.t(
'topic_statuses.autoclosed_topic_max_posts',
count: SiteSetting.auto_close_topics_post_count
count: SiteSetting.auto_close_topics_post_count,
locale: SiteSetting.default_locale
)
)
end

View File

@ -391,6 +391,26 @@ describe PostCreator do
expect(topic.closed).to eq(true)
expect(topic_timer.reload.deleted_at).to eq_time(Time.zone.now)
end
it "uses the system locale for the message" do
post
I18n.with_locale(:fr) do
PostCreator.new(
topic.user,
topic_id: topic.id,
raw: "this is a second post"
).create
end
topic.reload
expect(topic.posts.last.raw).to eq(I18n.t(
'topic_statuses.autoclosed_topic_max_posts',
count: SiteSetting.auto_close_topics_post_count,
locale: :en
))
end
end
end
end