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:
Robin Ward 2014-10-16 15:55:05 -04:00
commit 6ff97569ab
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