Defect #10578

Test case test_index_grouped_by_date (documents_controller_test.rb) fails depending upon local timezone.

Added by Milton Taylor about 7 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution: Affected version:


The fixtures load the documents table with test data that specifies timezone on timestamps of +01:00. (Paris). This persists to the database in local timezone, undergoing timezone conversion in the process. If local timezone is +11:00 this causes the date to be advanced to the next day in the database. The testcase then does an assertion check on the date returned by the controller, and it is returned in the default server (local) timezone, so it does not match the expected value in the test case.

Interestingly this was the only testcase in the whole set that fails for this reason.

Since it appears that most of the test data is in Paris timezone, when the tests are run it would seem desirable to force rails to use Paris as the local timezone, rather than using the server timezone. What is the correct way to do this?

Also available in: Atom PDF