13099-v2.patch

Takenori TAKAKI, 2021-08-17 15:04

Download (6.36 KB)

View differences:

app/controllers/reports_controller.rb
24 24
  def issue_report
25 25
    with_subprojects = Setting.display_subprojects_issues?
26 26
    @trackers = @project.rolled_up_trackers(with_subprojects).visible
27
    @versions = @project.shared_versions.sorted
27
    @versions = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")]
28 28
    @priorities = IssuePriority.all.reverse
29
    @categories = @project.issue_categories
30
    @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
29
    @categories = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")]
30
    @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")]
31 31
    @authors = @project.users.sorted
32 32
    @subprojects = @project.descendants.visible
33 33
    @issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
......
51 51
      @report_title = l(:field_tracker)
52 52
    when "version"
53 53
      @field = "fixed_version_id"
54
      @rows = @project.shared_versions.sorted
54
      @rows = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")]
55 55
      @data = Issue.by_version(@project, with_subprojects)
56 56
      @report_title = l(:field_version)
57 57
    when "priority"
......
61 61
      @report_title = l(:field_priority)
62 62
    when "category"
63 63
      @field = "category_id"
64
      @rows = @project.issue_categories
64
      @rows = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")]
65 65
      @data = Issue.by_category(@project, with_subprojects)
66 66
      @report_title = l(:field_category)
67 67
    when "assigned_to"
68 68
      @field = "assigned_to_id"
69
      @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
69
      @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")]
70 70
      @data = Issue.by_assigned_to(@project, with_subprojects)
71 71
      @report_title = l(:field_assigned_to)
72 72
    when "author"
app/helpers/reports_helper.rb
41 41
  end
42 42

  
43 43
  def aggregate_path(project, field, row, options={})
44
    parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options)
44
    parameters = {:set_filter => 1, :subproject_id => '!*', field => (row.id || '!*')}.merge(options)
45 45
    project_issues_path(row.is_a?(Project) ? row : project, parameters)
46 46
  end
47 47
end
app/models/issue.rb
1586 1586

  
1587 1587
    Issue.
1588 1588
      visible(User.current, :project => options[:project], :with_subprojects => options[:with_subprojects]).
1589
      joins(:status, assoc.name).
1589
      joins(:status).
1590 1590
      group(:status_id, :is_closed, select_field).
1591 1591
      count.
1592 1592
      map do |columns, total|
test/functional/reports_controller_test.rb
208 208
    end
209 209
  end
210 210

  
211
  def test_get_issue_report_details_by_assignee_should_show_non_assigned_issue_count
212
    Issue.delete_all
213
    Issue.generate!
214
    Issue.generate!
215
    Issue.generate!(:status_id => 5)
216
    Issue.generate!(:assigned_to_id => 2)
217

  
218
    get(
219
      :issue_report_details,
220
      :params => {
221
        :id => 1,
222
        :detail => 'assigned_to'
223
      }
224
    )
225
    assert_select 'table.list tbody :last-child' do
226
      assert_select 'td', :text => "[#{I18n.t(:label_none)}]"
227
      assert_select ':nth-child(2)', :text => '2' # status:1
228
      assert_select ':nth-child(6)', :text => '1' # status:5
229
      assert_select ':nth-child(8)', :text => '2' # open
230
      assert_select ':nth-child(9)', :text => '1' # closed
231
      assert_select ':nth-child(10)', :text => '3' # total
232
    end
233
  end
234

  
211 235
  def test_get_issue_report_details_with_an_invalid_detail
212 236
    get(
213 237
      :issue_report_details,
test/helpers/reports_helper_test.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-2021  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
require File.expand_path('../../test_helper', __FILE__)
21

  
22
class ReportsHlperTest < Redmine::HelperTest
23
  include ReportsHelper
24
  include Rails.application.routes.url_helpers
25

  
26
  fixtures :projects, :users
27

  
28
  def test_aggregate_path_for_spacified_row
29
    project = Project.find(1)
30
    field = 'assigned_to_id'
31
    row = User.find(2)
32
    assert_equal '/projects/ecookbook/issues?assigned_to_id=2&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row)
33
  end
34

  
35
  def test_aggregate_path_for_unset_row
36
    project = Project.find(1)
37
    field = 'assigned_to_id'
38
    row = User.new
39
    assert_equal '/projects/ecookbook/issues?assigned_to_id=%21%2A&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row)
40
  end
41
end