Patch #36241

MenuManagerTest randomly fails

Added by Mizuki ISHIKAWA 7 months ago. Updated 4 months ago.

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

0%

Category:Code cleanup/refactoring
Target version:5.0.0

Description

This test rarely fails.
This problem occurs because Project.visible(user).ids does not contain an ORDER clause for sorting and does not guarantee the order.

Failure:
MenuManagerTest#test_cross_project_menu_should_hide_item_if_module_is_not_enabled_for_any_project [/usr/src/redmine/test/integration/lib/redmine/menu_manager_test.rb:105]:
Expected: [1, 3, 4, 6]
  Actual: [6, 1, 3, 4]

rails test test/integration/lib/redmine/menu_manager_test.rb:103

Solved by the following patch.

diff --git a/test/integration/lib/redmine/menu_manager_test.rb b/test/integration/lib/redmine/menu_manager_test.rb
index 9bac57ad49..0456bc50e7 100644
--- a/test/integration/lib/redmine/menu_manager_test.rb
+++ b/test/integration/lib/redmine/menu_manager_test.rb
@@ -102,7 +102,7 @@ class MenuManagerTest < Redmine::IntegrationTest

   def test_cross_project_menu_should_hide_item_if_module_is_not_enabled_for_any_project
     user = User.find_by_login('dlopper')
-    assert_equal [1, 3, 4, 6], Project.visible(user).ids
+    assert_equal [1, 3, 4, 6], Project.visible(user).ids.sort

     # gantt and news are not enabled for any visible project
     Project.find(1).enabled_module_names = %w(issue_tracking calendar)


Related issues

Related to Redmine - Defect #36718: Menu Manager Test randomly fails Closed

Associated revisions

Revision 21297
Added by Go MAEDA 7 months ago

MenuManagerTest randomly fails (#36241).

Patch by Mizuki ISHIKAWA.

History

#1 Updated by Go MAEDA 7 months ago

  • Subject changed from MenuManagerTest#test_cross_project_menu_should_hide_item_if_module_is_not_enabled_for_any_project fails to MenuManagerTest randomly fails
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 5.0.0

Committed the fix. Thank you.

#2 Updated by Go MAEDA 4 months ago

  • Related to Defect #36718: Menu Manager Test randomly fails added

#3 Updated by Vincent Robert 4 months ago

Thank you for this fix. Is it possible to include it in the next minor version? 4.2.5?

#4 Updated by Go MAEDA 4 months ago

Vincent Robert wrote:

Thank you for this fix. Is it possible to include it in the next minor version? 4.2.5?

Such changes are usually not backported to stable branches. This is because there is no effect for general users and the number of such fixes is large. Also, developers usually use the trunk when they run the test suite.

Also available in: Atom PDF