FIX: Use default locale for moderator post when posts are moved

This commit is contained in:
Gerhard Schlager 2017-09-14 15:52:09 +02:00
parent f698de0bbf
commit efef422416
2 changed files with 21 additions and 3 deletions

View File

@ -154,11 +154,14 @@ class PostMover
def create_moderator_post_in_original_topic def create_moderator_post_in_original_topic
move_type_str = PostMover.move_types[@move_type].to_s move_type_str = PostMover.move_types[@move_type].to_s
original_topic.add_moderator_post( message = I18n.with_locale(SiteSetting.default_locale) do
user,
I18n.t("move_posts.#{move_type_str}_moderator_post", I18n.t("move_posts.#{move_type_str}_moderator_post",
count: post_ids.count, count: post_ids.count,
topic_link: "[#{destination_topic.title}](#{destination_topic.relative_url})"), topic_link: "[#{destination_topic.title}](#{destination_topic.relative_url})")
end
original_topic.add_moderator_post(
user, message,
post_type: Post.types[:small_action], post_type: Post.types[:small_action],
action_code: "split_topic", action_code: "split_topic",
post_number: @first_post_number_moved post_number: @first_post_number_moved

View File

@ -232,6 +232,21 @@ describe PostMover do
expect(new_topic.posts.pluck(:id).sort).to eq([p2.id, p3.id].sort) expect(new_topic.posts.pluck(:id).sort).to eq([p2.id, p3.id].sort)
end end
it "uses default locale for moderator post" do
I18n.locale = 'de'
new_topic = topic.move_posts(user, [p2.id, p4.id], title: "new testing topic name", category_id: category.id)
post = Post.find_by(topic_id: topic.id, post_type: Post.types[:small_action])
expected_text = I18n.with_locale(:en) do
I18n.t("move_posts.new_topic_moderator_post",
count: 2,
topic_link: "[#{new_topic.title}](#{new_topic.relative_url})")
end
expect(post.raw).to eq(expected_text)
end
end end
context "to an existing topic" do context "to an existing topic" do