FIX: Allow changing post owner even when topic validations fail

This commit is contained in:
Gerhard Schlager 2018-03-01 17:31:58 +01:00
parent 7a2183e8ab
commit a7c50039de
2 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@ class PostOwnerChanger
first_post_created_at: @new_owner.reload.posts.order('created_at ASC').first&.created_at
)
@topic.save!
@topic.save!(validate: false)
end
end
end

View File

@ -65,9 +65,14 @@ describe PostOwnerChanger do
it "changes the user even when the post does not pass validation" do
p1.update_attribute(:raw, "foo")
PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!
p1.reload
expect(p1.reload.user).to eq(user_a)
end
expect(p1.user).to eq(user_a)
it "changes the user even when the topic does not pass validation" do
topic.update_column(:title, "short")
PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!
expect(p1.reload.user).to eq(user_a)
end
context "integration tests" do