A platform for community discussion. Free, open, simple.
FIX: update 'posted' column on post owner change (#16367)
Faizaan Gagan1da4b9eeb3ff
diff --git a/app/services/post_owner_changer.rb b/app/services/post_owner_changer.rbindex c8f8e8f7f4c..702e6a8a178 100644--- a/app/services/post_owner_changer.rb+++ b/app/services/post_owner_changer.rb@@ -28,7 +28,7 @@ class PostOwnerChangerPostActionDestroyer.destroy(@new_owner, post, :like, skip_delete_check: true)level = post.is_first_post? ? :watching : :tracking- TopicUser.change(@new_owner.id, @topic.id, notification_level: NotificationLevels.topic_levels[level])+ TopicUser.change(@new_owner.id, @topic.id, notification_level: NotificationLevels.topic_levels[level], posted: true)if post == @topic.posts.order("post_number DESC").where("NOT hidden AND posts.deleted_at IS NULL").first@topic.last_poster = @new_ownerdiff --git a/spec/services/post_owner_changer_spec.rb b/spec/services/post_owner_changer_spec.rbindex 472c41b8fbc..4594a12d4a9 100644--- a/spec/services/post_owner_changer_spec.rb+++ b/spec/services/post_owner_changer_spec.rb@@ -85,6 +85,11 @@ describe PostOwnerChanger doexpect(p4.reload.user).to eq(user_a)end+ it "sets 'posted' for TopicUser to true" do+ PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!+ expect(TopicUser.find_by(topic_id: topic.id, user_id: user_a.id).posted).to eq(true)+ end+context "sets topic notification level for the new owner" dolet(:p4) { create_post(post_number: 2, topic: topic) }