[patch] When a post is split out to be a new topic

the topic's last_post_user_id is set to the user who split out
the post.  But, this should really be the user_id of the last post
of the split out posts.
This commit is contained in:
Michael Verdi 2014-10-16 12:38:26 -07:00
parent 4d465362b5
commit 1f95cfedc3
2 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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