Vote #80066
完了ApiTest fails if config.time_zone is set
0%
説明
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]: "2006-07-19T17:12:21Z " not found in "" 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 1 admin true Redmine Admin admin@somenet.foo 2006-07-20T02:12:21+09:00 2019-05-18T08:30:27+09:00 4bfca692e987af9ce73c77b1f31f79a11bbd3e4c 1
journals
Should we update the test code or always fix the time zone for API responses to UTC?
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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.
* [[Rest_Projects]]
* [[Rest_Issues]]
--------------------------------------------------------------------------------
I have fixed the API tests. It does not depend on UTC time zone.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Committed the patch. Thanks.
--------------------------------------------------------------------------------
Admin Redmine さんが3年以上前に更新
- カテゴリ を Code cleanup/refactoring_30 にセット
- 対象バージョン を 4.1.0_127 にセット