プロジェクト

全般

プロフィール

Vote #79617

完了

AttachmentsVisibilityTest and Redmine::AttachmentFieldFormatTest fail randomly due to uninitialized User.current

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

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

0%

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

説明

It looks like test/functional/attachments_visibility_test.rb has an unspecified dependency on the value of User.current. To reproduce:

bin/rails test test/integration/api_test/authentication_test.rb test/functional/attachments_visibility_test.rb --seed 53775

=>
Failure:
AttachmentsVisibilityTest#test_attachment_should_be_visible [/Users/gilad/Workspace/redmine/test/functional/attachments_visibility_test.rb:43]:
Expected response to be a <2XX: success>, but was a <403: Forbidden>
Environment:
  Redmine version                3.4.6.devel
  Ruby version                   2.4.1-p111 (2017-03-22) [x86_64-darwin17]
  Rails version                  5.2.1
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine plugins:
  no plugin installed

There are several tests that change User.current and don't reset the value to nil during teardown. In this case the culprit was the authorization_test.rb but I believe there are other tests that could potentially cause the same problem. I suggest adding User.current = nil to setup in the failing attachments_visibility_test.rb, and also adding the same to teardown in authorization_test.rb.


journals

Another related spec failure can be reproduced like this:

<pre>
bin/rails test test/integration/api_test/authentication_test.rb test/unit/lib/redmine/field_format/attachment_format_test.rb --seed 53775

=>
Failure:
Redmine::AttachmentFieldFormatTest#test_should_accept_a_hash_with_upload_on_create [/Users/gilad/Workspace/redmine/test/unit/lib/redmine/field_format/attachment_format_test.rb:45]:
--- expected
+++ actual
@@ -1 +1 @@
-#<CustomValue id: 284, customized_type: "Principal", customized_id: 133, custom_field_id: 46, value: "69">
+nil

Failure:
Redmine::AttachmentFieldFormatTest#test_should_replace_attachment_on_update [/Users/gilad/Workspace/redmine/test/unit/lib/redmine/field_format/attachment_format_test.rb:123]:
"Attachment.count" didn't change by 0.
Expected: 21
Actual: 22
</pre>

I've update the patch to address this as well.
--------------------------------------------------------------------------------
I know the test fails from time to time but I didn't know the reason. Thank you for investigating that.

The patch looks good. Setting target version to 4.1.0.
--------------------------------------------------------------------------------
Committed. Thank you for fixing those hard to find issues.
--------------------------------------------------------------------------------

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

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン4.0.0_99 にセット

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

いいね!0
いいね!0