diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 2b5f4127c68..0a834912c4c 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -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 diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index a14b9d1a3a9..d94eff72669 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -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