A platform for community discussion. Free, open, simple.
FIX: Validations could prevent moving posts
Gerhard Schlager0ecdf900230e
diff --git a/app/models/post_mover.rb b/app/models/post_mover.rbindex 79393fbf5db..7544a87ef15 100644--- a/app/models/post_mover.rb+++ b/app/models/post_mover.rb@@ -128,7 +128,8 @@ class PostMoverupdate[:reply_to_user_id] = nilend- post.update(update)+ post.attributes = update+ post.save(validate: false)move_incoming_emails(post, post)move_email_logs(post, post)diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex ded0639fca4..d48520a64e0 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -499,6 +499,17 @@ describe PostMover doendend+ 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)+ endendendend