diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 1e18ea3d3e..535ffe50d0 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -34,6 +34,8 @@ class PostMover ) DiscourseTagging.tag_topic_by_names(new_topic, Guardian.new(user), tags) move_posts_to new_topic + watch_new_topic + new_topic end end @@ -223,4 +225,13 @@ class PostMover destination_topic.update_columns(attrs) end end + + def watch_new_topic + TopicUser.change( + destination_topic.user, + destination_topic.id, + notification_level: TopicUser.notification_levels[:watching], + notifications_reason_id: TopicUser.notification_reasons[:created_topic] + ) + end end diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index 9f8e49778e..83d6a68d51 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -264,6 +264,19 @@ describe PostMover do moderator_post = topic.posts.last expect(moderator_post.raw).to include("2 posts were split") end + + it "forces resulting topic owner to watch the new topic" do + new_topic = topic.move_posts(user, [p2.id, p4.id], title: "new testing topic name", category_id: category.id) + + expect(new_topic.posts_count).to eq(2) + + expect(TopicUser.exists?( + user_id: another_user, + topic_id: new_topic.id, + notification_level: TopicUser.notification_levels[:watching], + notifications_reason_id: TopicUser.notification_reasons[:created_topic] + )).to eq(true) + end end context "to an existing topic" do