Project

General

Profile

Feature #28391 » 0002-adds-issue-category-column-to-spent-time-queries.patch

Marius BĂLTEANU, 2018-03-22 23:13

View differences:

app/models/time_entry_query.rb
30 30
    QueryColumn.new(:issue, :sortable => "#{Issue.table_name}.id"),
31 31
    QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.position"),
32 32
    QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.position"),
33
    QueryAssociationColumn.new(:issue, :category, :caption => :field_category, :sortable => "#{IssueCategory.table_name}.name"),
33 34
    QueryColumn.new(:comments),
34 35
    QueryColumn.new(:hours, :sortable => "#{TimeEntry.table_name}.hours", :totalable => true),
35 36
  ]
......
228 229
      if order_options.include?('trackers')
229 230
        joins << "LEFT OUTER JOIN #{Tracker.table_name} ON #{Tracker.table_name}.id = #{Issue.table_name}.tracker_id"
230 231
      end
232
      if order_options.include?('issue_categories')
233
        joins << "LEFT OUTER JOIN #{IssueCategory.table_name} ON #{IssueCategory.table_name}.id = #{Issue.table_name}.category_id"
234
      end
231 235
    end
232 236

  
233 237
    joins.compact!
test/functional/timelog_controller_test.rb
1036 1036
    assert_equal ['1', '2'], css_select('input[name="ids[]"]').map {|e| e.attr('value')}
1037 1037
  end
1038 1038

  
1039
  def test_index_with_issue_category_column
1040
    get :index, :params => {
1041
      :project_id => 'ecookbook',
1042
      :c => %w(project spent_on issue comments hours issue.category)
1043
    }
1044

  
1045
    assert_response :success
1046
    assert_select 'td.issue-category', :text => 'Printing'
1047
  end
1048

  
1049
  def test_index_with_issue_category_sort
1050
    issue = Issue.find(3)
1051
    issue.category_id = 2
1052
    issue.save!
1053

  
1054
    get :index, :params => {
1055
      :c => ["hours", 'issue.category'],
1056
      :sort => 'issue.category'
1057
    }
1058
    assert_response :success
1059

  
1060
    # Make sure that values are properly sorted
1061
    values = css_select("td.issue-category").map(&:text).reject(&:blank?)
1062
    assert_equal ['Printing', 'Printing', 'Recipes'], values
1063
  end
1064

  
1039 1065
  def test_index_with_filter_on_issue_custom_field
1040 1066
    issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
1041 1067
    entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
(2-2/2)