mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 18:05:37 +08:00
FIX: when changing owner of last post user list on topic incorrect
This commit is contained in:
parent
49502f4601
commit
b300d60086
|
@ -440,6 +440,11 @@ class Post < ActiveRecord::Base
|
||||||
)
|
)
|
||||||
|
|
||||||
revise(actor, { raw: self.raw, user_id: new_user.id, edit_reason: edit_reason })
|
revise(actor, { raw: self.raw, user_id: new_user.id, edit_reason: edit_reason })
|
||||||
|
|
||||||
|
if post_number == topic.highest_post_number
|
||||||
|
topic.update_columns(last_post_user_id: new_user.id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
|
|
|
@ -21,8 +21,9 @@ describe PostOwnerChanger do
|
||||||
|
|
||||||
it "changes the user" do
|
it "changes the user" do
|
||||||
old_user = p1.user
|
old_user = p1.user
|
||||||
described_class.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!
|
PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!
|
||||||
p1.reload
|
p1.reload
|
||||||
|
expect(p1.topic.last_post_user_id).to eq(user_a.id)
|
||||||
expect(old_user).not_to eq(p1.user)
|
expect(old_user).not_to eq(p1.user)
|
||||||
expect(p1.user).to eq(user_a)
|
expect(p1.user).to eq(user_a)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user