Project

General

Profile

Actions

Defect #28931

closed

Unreachable code in QueriesControllerTest#test_bulk_copy_to_another_project

Added by Pavel Rosický almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

this test probably never acually worked

Issue.order('id DESC').limit(issues.size)

issues.size was zero in rails < 5.2, it tests nothing

after this change it fails
https://github.com/rails/rails/commit/06f45435da941d713afefd3140421d1ced7abbdc

so I removed it


Files

issues_controller_test.rb.patch (535 Bytes) issues_controller_test.rb.patch Pavel Rosický, 2018-06-01 21:53

Related issues

Related to Redmine - Feature #23630: Migrate to Rails 5.2ClosedJean-Philippe Lang

Actions
Actions #1

Updated by Go MAEDA almost 6 years ago

Actions #2

Updated by Go MAEDA almost 6 years ago

I think it is better to modify the test to work rather than simply deleting it.

Index: test/functional/issues_controller_test.rb
===================================================================
--- test/functional/issues_controller_test.rb    (revision 17367)
+++ test/functional/issues_controller_test.rb    (working copy)
@@ -5967,10 +5967,11 @@

   def test_bulk_copy_to_another_project
     @request.session[:user_id] = 2
-    assert_difference 'Issue.count', 2 do
+    issue_ids = [1, 2]
+    assert_difference 'Issue.count', issue_ids.size do
       assert_no_difference 'Project.find(1).issues.count' do
         post :bulk_update, :params => {
-            :ids => [1, 2],
+            :ids => issue_ids,
             :issue => {
               :project_id => '2'
             },
@@ -5980,7 +5981,7 @@
     end
     assert_redirected_to '/projects/ecookbook/issues'

-    copies = Issue.order('id DESC').limit(issues.size)
+    copies = Issue.order('id DESC').limit(issue_ids.size)
     copies.each do |copy|
       assert_equal 2, copy.project_id
     end
Actions #3

Updated by Go MAEDA almost 6 years ago

  • Tracker changed from Patch to Defect
  • Subject changed from [Rails 5.2] fix spec test_bulk_copy_to_another_project to Unreachable code in QueriesControllerTest#test_bulk_copy_to_another_project
  • Assignee set to Go MAEDA
  • Target version set to 4.0.0
  • Resolution set to Fixed

Committed in r17372. Thank you for reporting this issue.

Actions #4

Updated by Go MAEDA almost 6 years ago

  • Status changed from New to Closed
Actions #5

Updated by Go MAEDA almost 6 years ago

Actions #6

Updated by Go MAEDA almost 6 years ago

Actions

Also available in: Atom PDF