If you're coding any functionality that has a dependency on time of day, do not use Time.now to mean the current time!
The reason is that Time.now returns the current time in the timezone where this computer (the one running the test) is located, but what you want is the time in the application's time zone.
We are making the application's time zone UTC (basically, GMT) since we will have users in all different time zones and each user can set the TZ in which they view and enter times. All times will be stored as UTC, and all time-dependent tasks will reckon time in UTC.
Therefore please use Time.zone.now to get the current time. Here is a good article on this gotcha. I've modified the Gemfile to include the timecop gem, which you can use to stub the clock in your tests.
If you're coding any functionality that has a dependency on time of day, do not use
Time.nowto mean the current time!The reason is that
Time.nowreturns the current time in the timezone where this computer (the one running the test) is located, but what you want is the time in the application's time zone.We are making the application's time zone UTC (basically, GMT) since we will have users in all different time zones and each user can set the TZ in which they view and enter times. All times will be stored as UTC, and all time-dependent tasks will reckon time in UTC.
Therefore please use
Time.zone.nowto get the current time. Here is a good article on this gotcha. I've modified the Gemfile to include thetimecopgem, which you can use to stub the clock in your tests.