From efef42241620bb935956415bdd92ad9555e6b448 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 14 Sep 2017 15:52:09 +0200 Subject: [PATCH] FIX: Use default locale for moderator post when posts are moved --- app/models/post_mover.rb | 9 ++++++--- spec/models/post_mover_spec.rb | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 0f492933edd..96f8f70588c 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -154,11 +154,14 @@ class PostMover def create_moderator_post_in_original_topic move_type_str = PostMover.move_types[@move_type].to_s - original_topic.add_moderator_post( - user, + message = I18n.with_locale(SiteSetting.default_locale) do I18n.t("move_posts.#{move_type_str}_moderator_post", 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], action_code: "split_topic", post_number: @first_post_number_moved diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index c573b7e9d0c..afc58a72b72 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -232,6 +232,21 @@ describe PostMover do expect(new_topic.posts.pluck(:id).sort).to eq([p2.id, p3.id].sort) 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 context "to an existing topic" do