A platform for community discussion. Free, open, simple.
FIX: Moving a topic's first post to an existing topic resets bumped_at (#35373)
Chris Alberti35fbaebe04e8
diff --git a/app/models/post_mover.rb b/app/models/post_mover.rbindex c22d23700dc..5655f506845 100644--- a/app/models/post_mover.rb+++ b/app/models/post_mover.rb@@ -277,6 +277,7 @@ class PostMovercreated_at: post.created_at,guardian: Guardian.new(user),skip_jobs: true,+ no_bump: true,)new_post = @post_creator.create!diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex f0069caa842..5fe7afb5b57 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -1183,6 +1183,93 @@ RSpec.describe PostMover doendend+ context "when moving old posts to an existing topic" do+ fab!(:from_topic) do+ Fabricate(+ :topic,+ user: user,+ created_at: 21.days.ago,+ bumped_at: 21.days.ago,+ updated_at: 21.days.ago,+ )+ end++ fab!(:to_topic) do+ Fabricate(+ :topic,+ user: user,+ created_at: 22.days.ago,+ bumped_at: 22.days.ago,+ updated_at: 22.days.ago,+ )+ end++ fab!(:to_p1) do+ Fabricate(+ :post,+ topic: to_topic,+ user: user,+ created_at: 9.days.ago,+ updated_at: 9.days.ago,+ )+ end++ fab!(:to_p2) do+ Fabricate(+ :post,+ topic: to_topic,+ user: user,+ created_at: 7.days.ago,+ updated_at: 7.days.ago,+ )+ end++ fab!(:from_p1) do+ Fabricate(+ :post,+ topic: from_topic,+ user: user,+ created_at: 8.days.ago,+ updated_at: 8.days.ago,+ )+ end++ fab!(:from_p2) do+ Fabricate(+ :post,+ topic: from_topic,+ user: user,+ created_at: 6.days.ago,+ updated_at: 6.days.ago,+ )+ end++ it "sets bumped_at correctly when first post gets moved" do+ # from_p1 was the first post in from_topic+ to_topic_bumped_at = to_topic.bumped_at+ moved_to =+ from_topic.move_posts(+ user,+ [from_p1.id],+ destination_topic_id: to_topic.id,+ chronological_order: true,+ )+ expect(moved_to.bumped_at).to eq_time(to_topic_bumped_at)+ end++ it "sets bumped_at correctly when moved post becomes latest post" do+ # from_p2 will be the latest post once moved+ moved_to =+ from_topic.move_posts(+ user,+ [from_p2.id],+ destination_topic_id: to_topic.id,+ chronological_order: true,+ )+ expect(moved_to.bumped_at).to eq_time(Time.zone.now)+ end+ end+context "when moved to a message" doit "works correctly" dotopic.expects(:add_moderator_post).once