mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Merge pull request #2880 from verdi327/set_last_post_user_id
[patch] When a post is split out to be a new topic
This commit is contained in:
commit
6ff97569ab
2 changed files with 8 additions and 0 deletions
|
@ -41,6 +41,7 @@ class PostMover
|
|||
notify_users_that_posts_have_moved
|
||||
update_statistics
|
||||
update_user_actions
|
||||
set_last_post_user_id(destination_topic)
|
||||
|
||||
destination_topic
|
||||
end
|
||||
|
@ -137,4 +138,10 @@ class PostMover
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_last_post_user_id(topic)
|
||||
user_id = topic.posts.last.user_id rescue nil
|
||||
return if user_id.nil?
|
||||
topic.update_attribute :last_post_user_id, user_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,6 +74,7 @@ describe PostMover do
|
|||
new_topic.reload
|
||||
new_topic.posts_count.should == 2
|
||||
new_topic.highest_post_number.should == 2
|
||||
new_topic.last_post_user_id.should == new_topic.posts.last.user_id
|
||||
expect(new_topic.last_posted_at).to be_present
|
||||
|
||||
p2.reload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue