0001-adds-issue-category-filter-to-spent-time-queries.patch

Marius BALTEANU, 2018-03-22 23:13

Download (3.24 KB)

View differences:

app/models/time_entry_query.rb
65 65
      :type => :list,
66 66
      :name => l("label_attribute_of_issue", :name => l(:field_fixed_version)),
67 67
      :values => lambda { fixed_version_values })
68
    add_available_filter "issue.category_id",
69
      :type => :list_optional,
70
      :name => l("label_attribute_of_issue", :name => l(:field_category)),
71
      :values => lambda { project.issue_categories.collect{|s| [s.name, s.id.to_s] } } if project
68 72

  
69 73
    add_available_filter("user_id",
70 74
      :type => :list_optional, :values => lambda { author_values }
......
197 201
    sql_for_field("status_id", operator, value, Issue.table_name, "status_id")
198 202
  end
199 203

  
204
  def sql_for_issue_category_id_field(field, operator, value)
205
    sql_for_field("category_id", operator, value, Issue.table_name, "category_id")
206
  end
207

  
200 208
  # Accepts :from/:to params as shortcut filters
201 209
  def build_from_params(params, defaults={})
202 210
    super
test/functional/timelog_controller_test.rb
1025 1025
    assert_equal Tracker.where(:id => [1, 2, 3]).sorted.pluck(:name), values
1026 1026
  end
1027 1027

  
1028
  def test_index_with_issue_category_filter
1029
    get :index, :params => {
1030
      :project_id => 'ecookbook',
1031
      :f => ['issue.category_id'],
1032
      :op => {'issue.category_id' => '='},
1033
      :v => {'issue.category_id' => ['1']}
1034
    }
1035
    assert_response :success
1036
    assert_equal ['1', '2'], css_select('input[name="ids[]"]').map {|e| e.attr('value')}
1037
  end
1038

  
1028 1039
  def test_index_with_filter_on_issue_custom_field
1029 1040
    issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
1030 1041
    entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
test/unit/time_entry_query_test.rb
102 102
    assert_include "issue.cf_#{field_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
103 103
    assert_not_include "issue.cf_#{field_not_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
104 104
  end
105

  
106
  def test_issue_category_filter_should_not_be_available_in_global_queries
107
    query = TimeEntryQuery.new(:project => nil, :name => '_')
108
    assert !query.available_filters.has_key?('issue.category_id')
109
  end
105 110
end
106
-