gitlabhq/gitlabhq — pull request #5344 by amacarthur (2013-10-16 05:50:54+00:00)
Title: Fixing unsafe use of Thread.current variable :current_user

ActivityObserver expects that the Thread.current[:current_user] be not nil in order to create an Event. This can sometimes be nil and cause an error. This error is often hidden by Thread.current[:current_user] being set unsafely without being reset to back to nil. If the thread is reused without this value being over-ridden, the incorrect current_user could be set.

You can see this behaviour occurring if you try running spec/requests/api/milestones.rb in a new thread.

I have tried to ensure that the variable gets set back to nil at all times.