Defect #30474

IssuesControllerTest#test_index_sort_by_total_estimated_hours tests practically nothing

Added by Go MAEDA 9 months ago. Updated 9 months ago.

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

0%

Category:Code cleanup/refactoring
Target version:4.1.0
Resolution: Affected version:

Description

IssuesControllerTest#test_index_sort_by_total_estimated_hours tries to test if the issues list is sorted by estimated hours, but it actually does not test anything.

In test/fixtures/issues.yml, all objects don't have estimate_hours value. As a result, the content of the array hours is always [nil, nil, nil, nil. nil]. Since all values in the array are the same, you cannot check whether the sorting works well or not.

  def test_index_sort_by_total_estimated_hours
    get :index, :params => {
        :sort => 'total_estimated_hours:desc'
      }
    assert_response :success
    hours = issues_in_list.map(&:total_estimated_hours)
    assert_equal hours.sort.reverse, hours
  end

fix-30474.diff Magnifier (1.33 KB) Go MAEDA, 2019-01-22 02:57

Associated revisions

Revision 17837
Added by Go MAEDA 9 months ago

IssuesControllerTest#test_index_sort_by_total_estimated_hours tests nothing (#30474).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA 9 months ago

Here is a patch to fix this. After applying this patch, the value of hours array is [200.0, 2.0, 1.0, 0.5] and the test can properly check the order of issues.

#2 Updated by Go MAEDA 9 months ago

  • Target version set to 4.1.0

Setting the target version to 4.1.0.

#3 Updated by Go MAEDA 9 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed.

Also available in: Atom PDF