Project

General

Profile

Actions

Defect #31388

closed

ApiTest fails if config.time_zone is set

Added by Go MAEDA almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

ApiTest fails if config.time_zone is set. The tests suppose that time in API response is always in UTC, but it varies depending on the value of config.time_zone is set.

Set config.time_zone in config/additional_environment.rb.

config.time_zone = 'Tokyo'

Run test/integration/api_test/api_test.rb. It fails. In the following example, the test expected that created_on in the response was "2006-07-19T17:12:21Z", but actually it was "2006-07-20T02:12:21+09:00".

$ bin/rails test test/integration/api_test/api_test.rb
Run options: --seed 57420

# Running:

.F

Failure:
Redmine::ApiTest::ApiTest#test_json_datetime_format [/Users/maeda/redmines/redmine-trunk/test/integration/api_test/api_test.rb:43]:
""created_on":"2006-07-19T17:12:21Z"" not found in "{"user":{"id":1,"login":"admin","admin":true,"firstname":"Redmine","lastname":"Admin","mail":"admin@somenet.foo","created_on":"2006-07-20T02:12:21+09:00","last_login_on":"2019-05-18T08:30:27+09:00","api_key":"9b0dd9bb5f4dcb890696137385999b2569f24631","status":1,"custom_fields":[{"id":4,"name":"Phone number","value":null},{"id":5,"name":"Money","value":null}]}}" 

bin/rails test test/integration/api_test/api_test.rb:41

.F

Failure:
Redmine::ApiTest::ApiTest#test_xml_datetime_format [/Users/maeda/redmines/redmine-trunk/test/integration/api_test/api_test.rb:48]:
"<created_on>2006-07-19T17:12:21Z</created_on>" not found in "<?xml version="1.0" encoding="UTF-8"?><user><id>1</id><login>admin</login><admin>true</admin><firstname>Redmine</firstname><lastname>Admin</lastname><mail>admin@somenet.foo</mail><created_on>2006-07-20T02:12:21+09:00</created_on><last_login_on>2019-05-18T08:30:27+09:00</last_login_on><api_key>4bfca692e987af9ce73c77b1f31f79a11bbd3e4c</api_key><status>1</status><custom_fields type="array"><custom_field id="4" name="Phone number"><value/></custom_field><custom_field id="5" name="Money"><value/></custom_field></custom_fields></user>" 

bin/rails test test/integration/api_test/api_test.rb:46

Finished in 1.001562s, 3.9938 runs/s, 5.9906 assertions/s.
4 runs, 6 assertions, 2 failures, 0 errors, 0 skips

Files

31388_apitest_failed.patch (1.87 KB) 31388_apitest_failed.patch Yuichi HARADA, 2019-06-07 04:59
Actions #1

Updated by Go MAEDA almost 5 years ago

Should we update the test code or always fix the time zone for API responses to UTC?

Actions #2

Updated by Go MAEDA almost 5 years ago

  • Description updated (diff)
Actions #3

Updated by Go MAEDA almost 5 years ago

  • Category changed from REST API to Code cleanup/refactoring

Go MAEDA wrote:

Should we update the test code or always fix the time zone for API responses to UTC?

I think we should fix the test, not API. Looking at the API documents, the time zone in the response is not supposed to be fixed to UTC.

Actions #4

Updated by Yuichi HARADA almost 5 years ago

I have fixed the API tests. It does not depend on UTC time zone.

Actions #5

Updated by Go MAEDA almost 5 years ago

  • Target version set to 4.1.0
Actions #6

Updated by Go MAEDA almost 5 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thanks.

Actions

Also available in: Atom PDF