diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index bc9605b6de..6f6d4c3135 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -24,10 +24,10 @@ class ReportsController < ApplicationController def issue_report with_subprojects = Setting.display_subprojects_issues? @trackers = @project.rolled_up_trackers(with_subprojects).visible - @versions = @project.shared_versions.sorted + @versions = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")] @priorities = IssuePriority.all.reverse - @categories = @project.issue_categories - @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + @categories = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")] + @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")] @authors = @project.users.sorted @subprojects = @project.descendants.visible @issues_by_tracker = Issue.by_tracker(@project, with_subprojects) @@ -51,7 +51,7 @@ class ReportsController < ApplicationController @report_title = l(:field_tracker) when "version" @field = "fixed_version_id" - @rows = @project.shared_versions.sorted + @rows = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")] @data = Issue.by_version(@project, with_subprojects) @report_title = l(:field_version) when "priority" @@ -61,12 +61,12 @@ class ReportsController < ApplicationController @report_title = l(:field_priority) when "category" @field = "category_id" - @rows = @project.issue_categories + @rows = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")] @data = Issue.by_category(@project, with_subprojects) @report_title = l(:field_category) when "assigned_to" @field = "assigned_to_id" - @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")] @data = Issue.by_assigned_to(@project, with_subprojects) @report_title = l(:field_assigned_to) when "author" diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 8f8e8eb84f..c64ccc768f 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -41,7 +41,7 @@ module ReportsHelper end def aggregate_path(project, field, row, options={}) - parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options) + parameters = {:set_filter => 1, :subproject_id => '!*', field => (row.id || '!*')}.merge(options) project_issues_path(row.is_a?(Project) ? row : project, parameters) end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 7ce04ad64b..5d4c111d25 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1586,7 +1586,7 @@ class Issue < ActiveRecord::Base Issue. visible(User.current, :project => options[:project], :with_subprojects => options[:with_subprojects]). - joins(:status, assoc.name). + joins(:status). group(:status_id, :is_closed, select_field). count. map do |columns, total| diff --git a/test/functional/reports_controller_test.rb b/test/functional/reports_controller_test.rb index f2b3e69f01..ca7ad67998 100644 --- a/test/functional/reports_controller_test.rb +++ b/test/functional/reports_controller_test.rb @@ -208,6 +208,30 @@ class ReportsControllerTest < Redmine::ControllerTest end end + def test_get_issue_report_details_by_assignee_should_show_non_assigned_issue_count + Issue.delete_all + Issue.generate! + Issue.generate! + Issue.generate!(:status_id => 5) + Issue.generate!(:assigned_to_id => 2) + + get( + :issue_report_details, + :params => { + :id => 1, + :detail => 'assigned_to' + } + ) + assert_select 'table.list tbody :last-child' do + assert_select 'td', :text => "[#{I18n.t(:label_none)}]" + assert_select ':nth-child(2)', :text => '2' # status:1 + assert_select ':nth-child(6)', :text => '1' # status:5 + assert_select ':nth-child(8)', :text => '2' # open + assert_select ':nth-child(9)', :text => '1' # closed + assert_select ':nth-child(10)', :text => '3' # total + end + end + def test_get_issue_report_details_with_an_invalid_detail get( :issue_report_details, diff --git a/test/helpers/reports_helper_test.rb b/test/helpers/reports_helper_test.rb new file mode 100644 index 0000000000..09ed6de1ab --- /dev/null +++ b/test/helpers/reports_helper_test.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006-2021 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.expand_path('../../test_helper', __FILE__) + +class ReportsHlperTest < Redmine::HelperTest + include ReportsHelper + include Rails.application.routes.url_helpers + + fixtures :projects, :users + + def test_aggregate_path_for_spacified_row + project = Project.find(1) + field = 'assigned_to_id' + row = User.find(2) + assert_equal '/projects/ecookbook/issues?assigned_to_id=2&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row) + end + + def test_aggregate_path_for_unset_row + project = Project.find(1) + field = 'assigned_to_id' + row = User.new + assert_equal '/projects/ecookbook/issues?assigned_to_id=%21%2A&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row) + end +end