##// END OF EJS Templates
Fixed that open/closed counts on issues summary are not displayed with SQLServer (#14369)....
Jean-Philippe Lang -
r11830:27c3299f3281
parent child
Show More
@@ -1,43 +1,43
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2013 Jean-Philippe Lang
4 # Copyright (C) 2006-2013 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
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
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.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module ReportsHelper
20 module ReportsHelper
21
21
22 def aggregate(data, criteria)
22 def aggregate(data, criteria)
23 a = 0
23 a = 0
24 data.each { |row|
24 data.each { |row|
25 match = 1
25 match = 1
26 criteria.each { |k, v|
26 criteria.each { |k, v|
27 match = 0 unless (row[k].to_s == v.to_s) || (k == 'closed' && row[k] == (v == 0 ? "f" : "t"))
27 match = 0 unless (row[k].to_s == v.to_s) || (k == 'closed' && (v == 0 ? ['f', false] : ['t', true]).include?(row[k]))
28 } unless criteria.nil?
28 } unless criteria.nil?
29 a = a + row["total"].to_i if match == 1
29 a = a + row["total"].to_i if match == 1
30 } unless data.nil?
30 } unless data.nil?
31 a
31 a
32 end
32 end
33
33
34 def aggregate_link(data, criteria, *args)
34 def aggregate_link(data, criteria, *args)
35 a = aggregate data, criteria
35 a = aggregate data, criteria
36 a > 0 ? link_to(h(a), *args) : '-'
36 a > 0 ? link_to(h(a), *args) : '-'
37 end
37 end
38
38
39 def aggregate_path(project, field, row, options={})
39 def aggregate_path(project, field, row, options={})
40 parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options)
40 parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options)
41 project_issues_path(row.is_a?(Project) ? row : project, parameters)
41 project_issues_path(row.is_a?(Project) ? row : project, parameters)
42 end
42 end
43 end
43 end
@@ -1,67 +1,85
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class ReportsControllerTest < ActionController::TestCase
20 class ReportsControllerTest < ActionController::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues,
21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :enumerations, :users, :issue_categories,
22 :enumerations, :users, :issue_categories,
23 :projects_trackers,
23 :projects_trackers,
24 :roles,
24 :roles,
25 :member_roles,
25 :member_roles,
26 :members,
26 :members,
27 :enabled_modules,
27 :enabled_modules,
28 :versions
28 :versions
29
29
30 def test_get_issue_report
30 def test_get_issue_report
31 get :issue_report, :id => 1
31 get :issue_report, :id => 1
32
32
33 assert_response :success
33 assert_response :success
34 assert_template 'issue_report'
34 assert_template 'issue_report'
35
35
36 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
36 [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
37 :issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar|
37 :issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar|
38 assert_not_nil assigns(ivar)
38 assert_not_nil assigns(ivar)
39 end
39 end
40
40
41 assert_equal IssuePriority.all.reverse, assigns(:priorities)
41 assert_equal IssuePriority.all.reverse, assigns(:priorities)
42 end
42 end
43
43
44 def test_get_issue_report_details
44 def test_get_issue_report_details
45 %w(tracker version priority category assigned_to author subproject).each do |detail|
45 %w(tracker version priority category assigned_to author subproject).each do |detail|
46 get :issue_report_details, :id => 1, :detail => detail
46 get :issue_report_details, :id => 1, :detail => detail
47
47
48 assert_response :success
48 assert_response :success
49 assert_template 'issue_report_details'
49 assert_template 'issue_report_details'
50 assert_not_nil assigns(:field)
50 assert_not_nil assigns(:field)
51 assert_not_nil assigns(:rows)
51 assert_not_nil assigns(:rows)
52 assert_not_nil assigns(:data)
52 assert_not_nil assigns(:data)
53 assert_not_nil assigns(:report_title)
53 assert_not_nil assigns(:report_title)
54 end
54 end
55 end
55 end
56
56
57 def test_get_issue_report_details_by_tracker_should_show_issue_count
58 Issue.delete_all
59 Issue.generate!(:tracker_id => 1)
60 Issue.generate!(:tracker_id => 1)
61 Issue.generate!(:tracker_id => 1, :status_id => 5)
62 Issue.generate!(:tracker_id => 2)
63
64 get :issue_report_details, :id => 1, :detail => 'tracker'
65 assert_select 'table.list tbody :nth-child(1)' do
66 assert_select 'td', :text => 'Bug'
67 assert_select ':nth-child(2)', :text => '2' # status:1
68 assert_select ':nth-child(3)', :text => '-' # status:2
69 assert_select ':nth-child(8)', :text => '2' # open
70 assert_select ':nth-child(9)', :text => '1' # closed
71 assert_select ':nth-child(10)', :text => '3' # total
72 end
73 end
74
57 def test_get_issue_report_details_by_priority
75 def test_get_issue_report_details_by_priority
58 get :issue_report_details, :id => 1, :detail => 'priority'
76 get :issue_report_details, :id => 1, :detail => 'priority'
59 assert_equal IssuePriority.all.reverse, assigns(:rows)
77 assert_equal IssuePriority.all.reverse, assigns(:rows)
60 end
78 end
61
79
62 def test_get_issue_report_details_with_an_invalid_detail
80 def test_get_issue_report_details_with_an_invalid_detail
63 get :issue_report_details, :id => 1, :detail => 'invalid'
81 get :issue_report_details, :id => 1, :detail => 'invalid'
64
82
65 assert_redirected_to '/projects/ecookbook/issues/report'
83 assert_redirected_to '/projects/ecookbook/issues/report'
66 end
84 end
67 end
85 end
General Comments 0
You need to be logged in to leave comments. Login now