プロジェクト

全般

プロフィール

Vote #80066

完了

ApiTest fails if config.time_zone is set

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
127
issue_org_id:
31388
author_id:
332
assigned_to_id:
332
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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 "1admintrueRedmineAdminadmin@somenet.foo2006-07-20T02:12:21+09:002019-05-18T08:30:27+09:004bfca692e987af9ce73c77b1f31f79a11bbd3e4c1"


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

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 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0