FIX: Validations could prevent moving posts

This commit is contained in:
Gerhard Schlager 2018-02-08 13:36:13 +01:00
parent 8ab6689f43
commit 0ecdf90023
2 changed files with 13 additions and 1 deletions

View File

@ -128,7 +128,8 @@ class PostMover
update[:reply_to_user_id] = nil
end
post.update(update)
post.attributes = update
post.save(validate: false)
move_incoming_emails(post, post)
move_email_logs(post, post)

View File

@ -499,6 +499,17 @@ describe PostMover do
end
end
it "skips validations when moving posts" do
p1.update_attribute(:raw, "foo")
p2.update_attribute(:raw, "bar")
new_topic = topic.move_posts(user, [p1.id, p2.id], title: "new testing topic name")
expect(new_topic).to be_present
expect(new_topic.posts.by_post_number.first.raw).to eq(p1.raw)
expect(new_topic.posts.by_post_number.last.raw).to eq(p2.raw)
expect(new_topic.posts_count).to eq(2)
end
end
end
end