Project

General

Profile

Actions

Defect #44708

open

attachment_transaction_test.rb reopens AttachmentTest and disables transactional tests for all its tests

Added by Go MAEDA about 23 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Resolution:
Affected version:

Description

test/unit/attachment_transaction_test.rb does not define its own test class. Instead, it reopens AttachmentTest, which is defined in test/unit/attachment_test.rb:

class AttachmentTest < ActiveSupport::TestCase
self.use_transactional_tests = false

When both files are loaded, as in a full test run (but not when attachment_test.rb is run alone), the settings in attachment_transaction_test.rb also apply to all tests in attachment_test.rb. This causes two problems:

  • The setup method in attachment_transaction_test.rb replaces the one in attachment_test.rb, so Attachment.clear_markdownized_previews is not called before each test.
  • Every test in AttachmentTest runs without a transaction, so all fixtures are deleted and reloaded before each test. In my development environment, where antivirus software (Sophos) scans files in real time, each test took 3 to 4 times longer (80 ms vs. 30 ms when run serially, and 200 ms vs. 50 ms with 8 parallel workers).

The attached patch fixes this by renaming the class in attachment_transaction_test.rb to AttachmentTransactionTest.


Files

No data to display

Actions

Also available in: Atom PDF