From 8ab6689f43fdf57ab303fc1ffa3f1bdd7d6dc46e Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 8 Feb 2018 12:55:32 +0100 Subject: [PATCH] FIX: Preserve original date when moving first post --- app/models/post_mover.rb | 1 + spec/models/post_mover_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 75e3cb16768..79393fbf5db 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -96,6 +96,7 @@ class PostMover via_email: post.via_email, raw_email: post.raw_email, skip_validations: true, + created_at: post.created_at, guardian: Guardian.new(user) ) diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index d483b354fa3..ded0639fca4 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -23,7 +23,7 @@ describe PostMover do let(:another_user) { Fabricate(:evil_trout) } let(:category) { Fabricate(:category, user: user) } let!(:topic) { Fabricate(:topic, user: user) } - let!(:p1) { Fabricate(:post, topic: topic, user: user) } + let!(:p1) { Fabricate(:post, topic: topic, user: user, created_at: 3.hours.ago) } let!(:p2) do Fabricate(:post, @@ -401,6 +401,7 @@ describe PostMover do # New first post new_first = new_topic.posts.where(post_number: 1).first expect(new_first.reply_count).to eq(1) + expect(new_first.created_at).to be_within(1.second).of(p1.created_at) # Second post is in a new topic p2.reload