Last Updated: February 25, 2016
·
1.934K
· norman

Use Time.zone.now in factories

If you do any timezone-sensitive calculations in your Rails application and you use Factory Girl and Timecop, make sure you don't set any datetime values using Time.now, but rather Time.zone.now. Otherwise you may end up with code that works on one machine but fails on another due to time zone setting difference.