FIX: Preserve original date when moving first post

This commit is contained in:
Gerhard Schlager 2018-02-08 12:55:32 +01:00
parent 190d208631
commit 8ab6689f43
2 changed files with 3 additions and 1 deletions

View File

@ -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)
)

View File

@ -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