Defect #29708

Wrong use of refute_includes in tests

Added by Felix Schäfer 15 days ago. Updated 15 days ago.

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

0%

Category:Code cleanup/refactoring
Target version:4.0.0
Resolution:Fixed Affected version:

Description

The refute_includes assertion expects the collection first and the object to test for after. The test in source:/trunk/test/functional/queries_controller_test.rb@17558#L627 uses the object then collection form though.

It seems most of Redmine tests use source:/trunk/test/test_helper.rb@17558#L205 assert_not_include which expects the object then collection form. The following patch corrects this problem:

--- a/test/functional/queries_controller_test.rb
+++ b/test/functional/queries_controller_test.rb
@@ -645,7 +645,7 @@ class QueriesControllerTest < Redmine::ControllerTest
     # response includes systemwide visible version
     assert_include ["OnlineStore - Systemwide visible version", "7", "open"], json
     # response doesn't include non visible version
-    refute_includes ["Private child of eCookbook - Private Version of public subproject", "6", "open"], json
+    assert_not_include ["Private child of eCookbook - Private Version of public subproject", "6", "open"], json
   end

   def test_subproject_filter_time_entries_with_project_id_should_return_filter_values

Associated revisions

Revision 17559
Added by Go MAEDA 15 days ago

Wrong use of refute_includes in tests (#29708).

Patch by Felix Schäfer.

History

#1 Updated by Mizuki ISHIKAWA 15 days ago

That makes sense to me.

refute_includes json, ["Private child of eCookbook - Private Version of public subproject", "6", "open"]

Although the test works with the above code, refute_includes is only used in redmine at three places.
assert_not_include is more familiar.

#2 Updated by Go MAEDA 15 days ago

  • Category set to Code cleanup/refactoring
  • Target version set to 4.1.0

#3 Updated by Go MAEDA 15 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.0 to 4.0.0
  • Resolution set to Fixed

Committed. Thanks.

Also available in: Atom PDF