Project

General

Profile

Defect #33281 » 33281.patch

Yuichi HARADA, 2020-04-22 07:55

View differences:

app/models/query.rb
755 755
  end
756 756

  
757 757
  def available_totalable_columns
758
    available_columns.select(&:totalable)
758
    available_columns.select(&:totalable).sort do |a, b|
759
      if a.is_a?(QueryCustomFieldColumn) && b.is_a?(QueryCustomFieldColumn)
760
        a.custom_field <=> b.custom_field
761
      else
762
        0
763
      end
764
    end
759 765
  end
760 766

  
761 767
  def default_columns_names
test/unit/query_test.rb
1802 1802
    assert_include "cf_#{field.id}".to_sym, q.available_totalable_columns.map(&:name)
1803 1803
  end
1804 1804

  
1805
  def test_available_totalable_columns_should_sort_in_position_order_for_custom_field
1806
    IssueCustomField.delete_all
1807
    cf_pos3 = IssueCustomField.generate!(:position => 3, :is_for_all => true, :field_format => 'int')
1808
    cf_pos4 = IssueCustomField.generate!(:position => 4, :is_for_all => true, :field_format => 'float')
1809
    cf_pos1 = IssueCustomField.generate!(:position => 1, :is_for_all => true, :field_format => 'float')
1810
    cf_pos2 = IssueCustomField.generate!(:position => 2, :is_for_all => true, :field_format => 'int')
1811
    q = IssueQuery.new
1812
    custom_field_columns = q.available_totalable_columns.select{|column| column.is_a?(QueryCustomFieldColumn)}
1813
    assert_equal [cf_pos1, cf_pos2, cf_pos3, cf_pos4], custom_field_columns.collect(&:custom_field)
1814
  end
1815

  
1805 1816
  def test_total_for_estimated_hours
1806 1817
    Issue.delete_all
1807 1818
    Issue.generate!(:estimated_hours => 5.5)
(3-3/5)