Vote #79617
完了AttachmentsVisibilityTest and Redmine::AttachmentFieldFormatTest fail randomly due to uninitialized User.current
0%
説明
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 にセット