Patch #32122

Fix test failure due to missing call to set_tmp_attachments_directory

Added by Yuichi HARADA 3 months ago. Updated 2 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Code cleanup/refactoring
Target version:4.1.0

Description

https://www.redmine.org/builds/logs/build_trunk_postgresql_ruby-2.4_583.html

...F

Failure:
AttachmentsControllerTest#test_download_should_assign_content_type_if_blank [/var/lib/jenkins/workspace/trunk/DATABASE_ADAPTER/postgresql/RUBY_VER/ruby-2.4/test/functional/attachments_controller_test.rb:345]:
Expected response to be a <2XX: success>, but was a <404: Not Found>

bin/rails test test/functional/attachments_controller_test.rb:339

.........................................................................................................F

Failure:
Redmine::ApiTest::AttachmentsTest#test_GET_/attachments/thumbnail/:id_should_return_the_thumbnail [/var/lib/jenkins/workspace/trunk/DATABASE_ADAPTER/postgresql/RUBY_VER/ruby-2.4/test/integration/api_test/attachments_test.rb:83]:
Expected response to be a <2XX: success>, but was a <404: Not Found>

bin/rails test test/integration/api_test/attachments_test.rb:80

...F

Failure:
Redmine::ApiTest::AttachmentsTest#test_GET_/attachments/:id.xml_for_image_should_include_thumbnail_url [/var/lib/jenkins/workspace/trunk/DATABASE_ADAPTER/postgresql/RUBY_VER/ruby-2.4/test/integration/api_test/attachments_test.rb:54]:
Expected response to be a <2XX: success>, but was a <404: Not Found>
Response body: 

bin/rails test test/integration/api_test/attachments_test.rb:52

....................................................................................................................................................................................................................................................................F

Failure:
ApplicationHelperTest#test_attached_images_should_read_later [/var/lib/jenkins/workspace/trunk/DATABASE_ADAPTER/postgresql/RUBY_VER/ruby-2.4/test/helpers/application_helper_test.rb:249]:
Expected false to be truthy.

bin/rails test test/helpers/application_helper_test.rb:245

.........................................................................................................F

Failure:
AttachmentsTest#test_download_should_set_sendfile_header [/var/lib/jenkins/workspace/trunk/DATABASE_ADAPTER/postgresql/RUBY_VER/ruby-2.4/test/integration/attachments_test.rb:153]:
Expected response to be a <2XX: success>, but was a <404: Not Found>

bin/rails test test/integration/attachments_test.rb:148

I think the reason why the test failed is that Attachments under test/fixtures/files/ is missing.
I think I should call to set_tmp_attachments_directory . I attached a patch.

add_call_to_set_tmp_attachments_directory.patch Magnifier (19.7 KB) Yuichi HARADA, 2019-09-24 03:53

Associated revisions

Revision 18593
Added by Go MAEDA 2 months ago

Fix test failure due to missing call to set_tmp_attachments_directory (#32122).

Patch by Yuichi HARADA.

History

#1 Updated by Go MAEDA 3 months ago

  • Target version set to Candidate for next major release

#2 Updated by Go MAEDA 2 months ago

  • Assignee set to Go MAEDA
  • Target version changed from Candidate for next major release to 4.2.0

LGTM. Setting the target version to 4.2.0.

set_tmp_attachments_directory and set_fixtures_attachments_directory are methods which change Attachment.storage_path during tests.

If a test method which creates/deletes attachments, set_tmp_attachments_directory has to be called at the beginning of the method in order not to destroy the contents in test/fixtures/files directory. Some test methods which uses files in test/fixtures/files call set_fixtures_attachments_directory in order to set Attachment.storage_path to test/fixtures/files. Those test methods should call set_tmp_attachments_directory at the end. Otherwise, you may observe some test failures.

This patch ensures calling set_tmp_attachments_directory in some tests, in order to fix test failures which occurs occasionally.

#3 Updated by Go MAEDA 2 months ago

  • Subject changed from Add call to set_tmp_attachments_directory to Fix test failure due to missing call to set_tmp_attachments_directory

#4 Updated by Go MAEDA 2 months ago

  • Status changed from New to Closed
  • Target version changed from 4.2.0 to 4.1.0

Committed the patch. Thank you for investigating the test failure.

Also available in: Atom PDF