Feature #2529 » feature_2629_v3.patch
app/controllers/reports_controller.rb | ||
---|---|---|
27 | 27 |
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
28 | 28 |
@authors = @project.users.sort |
29 | 29 |
@subprojects = @project.descendants.visible |
30 | ||
31 |
@issues_by_tracker = Issue.by_tracker(@project) |
|
32 |
@issues_by_version = Issue.by_version(@project) |
|
33 |
@issues_by_priority = Issue.by_priority(@project) |
|
34 |
@issues_by_category = Issue.by_category(@project) |
|
35 |
@issues_by_assigned_to = Issue.by_assigned_to(@project) |
|
36 |
@issues_by_author = Issue.by_author(@project) |
|
30 |
with_subprojects = Setting.display_subprojects_issues? |
|
31 |
@issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
|
|
32 |
@issues_by_version = Issue.by_version(@project, with_subprojects)
|
|
33 |
@issues_by_priority = Issue.by_priority(@project, with_subprojects)
|
|
34 |
@issues_by_category = Issue.by_category(@project, with_subprojects)
|
|
35 |
@issues_by_assigned_to = Issue.by_assigned_to(@project, with_subprojects)
|
|
36 |
@issues_by_author = Issue.by_author(@project, with_subprojects)
|
|
37 | 37 |
@issues_by_subproject = Issue.by_subproject(@project) || [] |
38 | 38 | |
39 | 39 |
render :template => "reports/issue_report" |
40 | 40 |
end |
41 | 41 | |
42 | 42 |
def issue_report_details |
43 |
with_subprojects = Setting.display_subprojects_issues? |
|
43 | 44 |
case params[:detail] |
44 | 45 |
when "tracker" |
45 | 46 |
@field = "tracker_id" |
46 | 47 |
@rows = @project.rolled_up_trackers(false).visible |
47 |
@data = Issue.by_tracker(@project) |
|
48 |
@data = Issue.by_tracker(@project, with_subprojects)
|
|
48 | 49 |
@report_title = l(:field_tracker) |
49 | 50 |
when "version" |
50 | 51 |
@field = "fixed_version_id" |
51 | 52 |
@rows = @project.shared_versions.sort |
52 |
@data = Issue.by_version(@project) |
|
53 |
@data = Issue.by_version(@project, with_subprojects)
|
|
53 | 54 |
@report_title = l(:field_version) |
54 | 55 |
when "priority" |
55 | 56 |
@field = "priority_id" |
56 | 57 |
@rows = IssuePriority.all.reverse |
57 |
@data = Issue.by_priority(@project) |
|
58 |
@data = Issue.by_priority(@project, with_subprojects)
|
|
58 | 59 |
@report_title = l(:field_priority) |
59 | 60 |
when "category" |
60 | 61 |
@field = "category_id" |
61 | 62 |
@rows = @project.issue_categories |
62 |
@data = Issue.by_category(@project) |
|
63 |
@data = Issue.by_category(@project, with_subprojects)
|
|
63 | 64 |
@report_title = l(:field_category) |
64 | 65 |
when "assigned_to" |
65 | 66 |
@field = "assigned_to_id" |
66 | 67 |
@rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
67 |
@data = Issue.by_assigned_to(@project) |
|
68 |
@data = Issue.by_assigned_to(@project, with_subprojects)
|
|
68 | 69 |
@report_title = l(:field_assigned_to) |
69 | 70 |
when "author" |
70 | 71 |
@field = "author_id" |
71 | 72 |
@rows = @project.users.sort |
72 |
@data = Issue.by_author(@project) |
|
73 |
@data = Issue.by_author(@project, with_subprojects)
|
|
73 | 74 |
@report_title = l(:field_author) |
74 | 75 |
when "subproject" |
75 | 76 |
@field = "project_id" |
app/models/issue.rb | ||
---|---|---|
1464 | 1464 |
end |
1465 | 1465 |
end |
1466 | 1466 | |
1467 |
def self.by_tracker(project) |
|
1468 |
count_and_group_by(:project => project, :association => :tracker) |
|
1467 |
def self.by_tracker(project, with_subprojects=false)
|
|
1468 |
count_and_group_by(:project => project, :association => :tracker, :with_subprojects => with_subprojects)
|
|
1469 | 1469 |
end |
1470 | 1470 | |
1471 |
def self.by_version(project) |
|
1472 |
count_and_group_by(:project => project, :association => :fixed_version) |
|
1471 |
def self.by_version(project, with_subprojects=false)
|
|
1472 |
count_and_group_by(:project => project, :association => :fixed_version, :with_subprojects => with_subprojects)
|
|
1473 | 1473 |
end |
1474 | 1474 | |
1475 |
def self.by_priority(project) |
|
1476 |
count_and_group_by(:project => project, :association => :priority) |
|
1475 |
def self.by_priority(project, with_subprojects=false)
|
|
1476 |
count_and_group_by(:project => project, :association => :priority, :with_subprojects => with_subprojects)
|
|
1477 | 1477 |
end |
1478 | 1478 | |
1479 |
def self.by_category(project) |
|
1480 |
count_and_group_by(:project => project, :association => :category) |
|
1479 |
def self.by_category(project, with_subprojects=false)
|
|
1480 |
count_and_group_by(:project => project, :association => :category, :with_subprojects => with_subprojects)
|
|
1481 | 1481 |
end |
1482 | 1482 | |
1483 |
def self.by_assigned_to(project) |
|
1484 |
count_and_group_by(:project => project, :association => :assigned_to) |
|
1483 |
def self.by_assigned_to(project, with_subprojects=false)
|
|
1484 |
count_and_group_by(:project => project, :association => :assigned_to, :with_subprojects => with_subprojects)
|
|
1485 | 1485 |
end |
1486 | 1486 | |
1487 |
def self.by_author(project) |
|
1488 |
count_and_group_by(:project => project, :association => :author) |
|
1487 |
def self.by_author(project, with_subprojects=false)
|
|
1488 |
count_and_group_by(:project => project, :association => :author, :with_subprojects => with_subprojects)
|
|
1489 | 1489 |
end |
1490 | 1490 | |
1491 | 1491 |
def self.by_subproject(project) |
app/views/reports/_details.html.erb | ||
---|---|---|
14 | 14 |
<tbody> |
15 | 15 |
<% for row in rows %> |
16 | 16 |
<tr> |
17 |
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row) %></td> |
|
17 |
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
|
|
18 | 18 |
<% for status in @statuses %> |
19 |
<td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id) %></td> |
|
19 |
<td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id, :subproject_id => nil) %></td>
|
|
20 | 20 |
<% end %> |
21 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %></td> |
|
22 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %></td> |
|
23 |
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %></td> |
|
21 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
|
|
22 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
|
|
23 |
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
|
|
24 | 24 |
</tr> |
25 | 25 |
<% end %> |
26 | 26 |
</tbody> |
app/views/reports/_simple.html.erb | ||
---|---|---|
11 | 11 |
<tbody> |
12 | 12 |
<% for row in rows %> |
13 | 13 |
<tr> |
14 |
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row) %></td> |
|
15 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %></td> |
|
16 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %></td> |
|
17 |
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %></td> |
|
14 |
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
|
|
15 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
|
|
16 |
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
|
|
17 |
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
|
|
18 | 18 |
</tr> |
19 | 19 |
<% end %> |
20 | 20 |
</tbody> |
test/functional/reports_controller_test.rb | ||
---|---|---|
34 | 34 |
assert_response :success |
35 | 35 |
end |
36 | 36 | |
37 |
def test_issue_report_when_displaying_subprojects_issues |
|
38 |
Setting.stubs(:display_subprojects_issues?).returns(true) |
|
39 |
get :issue_report, :params => { |
|
40 |
:id => 1 |
|
41 |
} |
|
42 | ||
43 |
assert_response :success |
|
44 |
# Count subprojects issues |
|
45 |
assert_select 'table.list tbody :nth-child(1):first' do |
|
46 |
assert_select 'td', :text => 'Bug' |
|
47 |
assert_select ':nth-child(2)', :text => '5' # open |
|
48 |
assert_select ':nth-child(3)', :text => '3' # closed |
|
49 |
assert_select ':nth-child(4)', :text => '8' # total |
|
50 |
end |
|
51 |
end |
|
52 | ||
53 |
def test_issue_report_when_not_displaying_subprojects_issues |
|
54 |
Setting.stubs(:display_subprojects_issues?).returns(false) |
|
55 |
get :issue_report, :params => { |
|
56 |
:id => 1 |
|
57 |
} |
|
58 | ||
59 |
assert_response :success |
|
60 |
# Do not count subprojects issues |
|
61 |
assert_select 'table.list tbody :nth-child(1):first' do |
|
62 |
assert_select 'td', :text => 'Bug' |
|
63 |
assert_select ':nth-child(2)', :text => '3' # open |
|
64 |
assert_select ':nth-child(3)', :text => '3' # closed |
|
65 |
assert_select ':nth-child(4)', :text => '6' # total |
|
66 |
end |
|
67 |
end |
|
68 | ||
37 | 69 |
def test_get_issue_report_details |
38 | 70 |
%w(tracker version priority category assigned_to author subproject).each do |detail| |
39 | 71 |
get :issue_report_details, :params => { |
... | ... | |
45 | 77 |
end |
46 | 78 | |
47 | 79 |
def test_get_issue_report_details_by_tracker_should_show_only_statuses_used_by_the_project |
80 |
Setting.stubs(:display_subprojects_issues?).returns(false) |
|
48 | 81 |
WorkflowTransition.delete_all |
49 | 82 |
WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5) |
50 | 83 |
WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4) |
... | ... | |
70 | 103 |
end |
71 | 104 |
end |
72 | 105 | |
106 |
def test_get_issue_report_details_by_tracker_when_displaying_subprojects_issues |
|
107 |
Setting.stubs(:display_subprojects_issues?).returns(true) |
|
108 |
get :issue_report_details, :params => { |
|
109 |
:id => 1, |
|
110 |
:detail => 'tracker' |
|
111 |
} |
|
112 | ||
113 |
assert_response :success |
|
114 |
# Count subprojects issues |
|
115 |
assert_select 'table.list tbody :nth-child(1)' do |
|
116 |
assert_select 'td', :text => 'Bug' |
|
117 |
assert_select ':nth-child(2)', :text => '5' # status:1 |
|
118 |
assert_select ':nth-child(3)', :text => '-' # status:2 |
|
119 |
assert_select ':nth-child(4)', :text => '-' # status:3 |
|
120 |
assert_select ':nth-child(5)', :text => '-' # status:4 |
|
121 |
assert_select ':nth-child(6)', :text => '3' # status:5 |
|
122 |
assert_select ':nth-child(7)', :text => '-' # status:6 |
|
123 |
assert_select ':nth-child(8)', :text => '5' # open |
|
124 |
assert_select ':nth-child(9)', :text => '3' # closed |
|
125 |
assert_select ':nth-child(10)', :text => '8' # total |
|
126 |
end |
|
127 |
end |
|
128 | ||
129 |
def test_get_issue_report_details_by_tracker_when_not_displaying_subprojects_issues |
|
130 |
Setting.stubs(:display_subprojects_issues?).returns(false) |
|
131 |
get :issue_report_details, :params => { |
|
132 |
:id => 1, |
|
133 |
:detail => 'tracker' |
|
134 |
} |
|
135 | ||
136 |
assert_response :success |
|
137 |
# Do not count subprojects issues |
|
138 |
assert_select 'table.list tbody :nth-child(1)' do |
|
139 |
assert_select 'td', :text => 'Bug' |
|
140 |
assert_select ':nth-child(2)', :text => '3' # status:1 |
|
141 |
assert_select ':nth-child(3)', :text => '-' # status:2 |
|
142 |
assert_select ':nth-child(4)', :text => '-' # status:3 |
|
143 |
assert_select ':nth-child(5)', :text => '-' # status:4 |
|
144 |
assert_select ':nth-child(6)', :text => '3' # status:5 |
|
145 |
assert_select ':nth-child(7)', :text => '-' # status:6 |
|
146 |
assert_select ':nth-child(8)', :text => '3' # open |
|
147 |
assert_select ':nth-child(9)', :text => '3' # closed |
|
148 |
assert_select ':nth-child(10)', :text => '6' # total |
|
149 |
end |
|
150 |
end |
|
151 | ||
73 | 152 |
def test_get_issue_report_details_by_tracker_should_show_issue_count |
74 | 153 |
Issue.delete_all |
75 | 154 |
Issue.generate!(:tracker_id => 1) |
test/unit/issue_test.rb | ||
---|---|---|
2756 | 2756 |
end |
2757 | 2757 | |
2758 | 2758 |
test "#by_tracker" do |
2759 |
User.current = User.anonymous
|
|
2759 |
User.current = User.find(2)
|
|
2760 | 2760 |
groups = Issue.by_tracker(Project.find(1)) |
2761 |
assert_equal 3, groups.count
|
|
2761 |
groups_containing_subprojects = Issue.by_tracker(Project.find(1), true)
|
|
2762 | 2762 |
assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2763 |
assert_equal 13, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2763 | 2764 |
end |
2764 | 2765 | |
2765 | 2766 |
test "#by_version" do |
2766 |
User.current = User.anonymous |
|
2767 |
groups = Issue.by_version(Project.find(1)) |
|
2768 |
assert_equal 3, groups.count |
|
2767 |
User.current = User.find(2) |
|
2768 |
project = Project.find(1) |
|
2769 |
Issue.generate!(:project_id => project.descendants.visible.first, :fixed_version_id => project.shared_versions.find_by(:sharing => 'tree').id) |
|
2770 | ||
2771 |
groups = Issue.by_version(project) |
|
2772 |
groups_containing_subprojects = Issue.by_version(project, true) |
|
2769 | 2773 |
assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2774 |
assert_equal 4, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2770 | 2775 |
end |
2771 | 2776 | |
2772 | 2777 |
test "#by_priority" do |
2773 |
User.current = User.anonymous |
|
2774 |
groups = Issue.by_priority(Project.find(1)) |
|
2775 |
assert_equal 4, groups.count |
|
2778 |
User.current = User.find(2) |
|
2779 |
project = Project.find(1) |
|
2780 |
groups = Issue.by_priority(project) |
|
2781 |
groups_containing_subprojects = Issue.by_priority(project, true) |
|
2776 | 2782 |
assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2783 |
assert_equal 13, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2777 | 2784 |
end |
2778 | 2785 | |
2779 | 2786 |
test "#by_category" do |
2780 |
User.current = User.anonymous |
|
2781 |
groups = Issue.by_category(Project.find(1)) |
|
2782 |
assert_equal 2, groups.count |
|
2787 |
User.current = User.find(2) |
|
2788 |
project = Project.find(1) |
|
2789 |
issue_category = IssueCategory.create(:project => project.descendants.visible.first, :name => 'test category') |
|
2790 |
Issue.generate!(:project_id => project.descendants.visible.first, :category_id => issue_category.id) |
|
2791 | ||
2792 |
groups = Issue.by_category(project) |
|
2793 |
groups_containing_subprojects = Issue.by_category(project, true) |
|
2783 | 2794 |
assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2795 |
assert_equal 4, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2784 | 2796 |
end |
2785 | 2797 | |
2786 | 2798 |
test "#by_assigned_to" do |
2787 |
User.current = User.anonymous |
|
2788 |
groups = Issue.by_assigned_to(Project.find(1)) |
|
2789 |
assert_equal 2, groups.count |
|
2799 |
User.current = User.find(2) |
|
2800 |
project = Project.find(1) |
|
2801 |
Issue.generate!(:project_id => project.descendants.visible.first, :assigned_to => User.current) |
|
2802 | ||
2803 |
groups = Issue.by_assigned_to(project) |
|
2804 |
groups_containing_subprojects = Issue.by_assigned_to(project, true) |
|
2790 | 2805 |
assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2806 |
assert_equal 3, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2791 | 2807 |
end |
2792 | 2808 | |
2793 | 2809 |
test "#by_author" do |
2794 |
User.current = User.anonymous |
|
2795 |
groups = Issue.by_author(Project.find(1)) |
|
2796 |
assert_equal 4, groups.count |
|
2810 |
User.current = User.find(2) |
|
2811 |
project = Project.find(1) |
|
2812 |
groups = Issue.by_author(project) |
|
2813 |
groups_containing_subprojects = Issue.by_author(project, true) |
|
2797 | 2814 |
assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i} |
2815 |
assert_equal 13, groups_containing_subprojects.inject(0) {|sum, group| sum + group['total'].to_i} |
|
2798 | 2816 |
end |
2799 | 2817 | |
2800 | 2818 |
test "#by_subproject" do |
- « Previous
- 1
- 2
- 3
- 4
- Next »