Fixing unsafe use of Thread.current variable :current_user
Created by: amacarthur
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.