@@ -0,0 +1,53 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2014 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
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 | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
|
19 | ||
|
20 | class VersionsHelperTest < ActionView::TestCase | |
|
21 | ||
|
22 | fixtures :projects, :versions | |
|
23 | ||
|
24 | def test_version_filtered_issues_path_sharing_none | |
|
25 | version = Version.new(:name => 'test', :sharing => 'none') | |
|
26 | version.project = Project.find(5) | |
|
27 | assert_match '/projects/private-child/issues?', version_filtered_issues_path(version) | |
|
28 | end | |
|
29 | ||
|
30 | def test_version_filtered_issues_path_sharing_descendants | |
|
31 | version = Version.new(:name => 'test', :sharing => 'descendants') | |
|
32 | version.project = Project.find(5) | |
|
33 | assert_match '/projects/private-child/issues?', version_filtered_issues_path(version) | |
|
34 | end | |
|
35 | ||
|
36 | def test_version_filtered_issues_path_sharing_hierarchy | |
|
37 | version = Version.new(:name => 'test', :sharing => 'hierarchy') | |
|
38 | version.project = Project.find(5) | |
|
39 | assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version) | |
|
40 | end | |
|
41 | ||
|
42 | def test_version_filtered_issues_path_sharing_tree | |
|
43 | version = Version.new(:name => 'test', :sharing => 'tree') | |
|
44 | version.project = Project.find(5) | |
|
45 | assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version) | |
|
46 | end | |
|
47 | ||
|
48 | def test_version_filtered_issues_path_sharing_system | |
|
49 | version = Version.new(:name => 'test', :sharing => 'system') | |
|
50 | version.project = Project.find(5) | |
|
51 | assert_match /^\/issues\?/, version_filtered_issues_path(version) | |
|
52 | end | |
|
53 | end |
@@ -1,54 +1,76 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | # |
|
3 | 3 | # Redmine - project management software |
|
4 | 4 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
5 | 5 | # |
|
6 | 6 | # This program is free software; you can redistribute it and/or |
|
7 | 7 | # modify it under the terms of the GNU General Public License |
|
8 | 8 | # as published by the Free Software Foundation; either version 2 |
|
9 | 9 | # of the License, or (at your option) any later version. |
|
10 | 10 | # |
|
11 | 11 | # This program is distributed in the hope that it will be useful, |
|
12 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 | # GNU General Public License for more details. |
|
15 | 15 | # |
|
16 | 16 | # You should have received a copy of the GNU General Public License |
|
17 | 17 | # along with this program; if not, write to the Free Software |
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 | 19 | |
|
20 | 20 | module VersionsHelper |
|
21 | 21 | |
|
22 | 22 | def version_anchor(version) |
|
23 | 23 | if @project == version.project |
|
24 | 24 | anchor version.name |
|
25 | 25 | else |
|
26 | 26 | anchor "#{version.project.try(:identifier)}-#{version.name}" |
|
27 | 27 | end |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | def version_filtered_issues_path(version, options = {}) | |
|
31 | options = {:fixed_version_id => version, :set_filter => 1}.merge(options) | |
|
32 | project = case version.sharing | |
|
33 | when 'hierarchy', 'tree' | |
|
34 | if version.project && version.project.root.visible? | |
|
35 | version.project.root | |
|
36 | else | |
|
37 | version.project | |
|
38 | end | |
|
39 | when 'system' | |
|
40 | nil | |
|
41 | else | |
|
42 | version.project | |
|
43 | end | |
|
44 | ||
|
45 | if project | |
|
46 | project_issues_path(project, options) | |
|
47 | else | |
|
48 | issues_path(options) | |
|
49 | end | |
|
50 | end | |
|
51 | ||
|
30 | 52 | STATUS_BY_CRITERIAS = %w(tracker status priority author assigned_to category) |
|
31 | 53 | |
|
32 | 54 | def render_issue_status_by(version, criteria) |
|
33 | 55 | criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria) |
|
34 | 56 | |
|
35 | 57 | h = Hash.new {|k,v| k[v] = [0, 0]} |
|
36 | 58 | begin |
|
37 | 59 | # Total issue count |
|
38 | 60 | Issue.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][0] = s} |
|
39 | 61 | # Open issues count |
|
40 | 62 | Issue.open.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][1] = s} |
|
41 | 63 | rescue ActiveRecord::RecordNotFound |
|
42 | 64 | # When grouping by an association, Rails throws this exception if there's no result (bug) |
|
43 | 65 | end |
|
44 | 66 | # Sort with nil keys in last position |
|
45 | 67 | counts = h.keys.sort {|a,b| a.nil? ? 1 : (b.nil? ? -1 : a <=> b)}.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} |
|
46 | 68 | max = counts.collect {|c| c[:total]}.max |
|
47 | 69 | |
|
48 | 70 | render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max} |
|
49 | 71 | end |
|
50 | 72 | |
|
51 | 73 | def status_by_options_for_select(value) |
|
52 | 74 | options_for_select(STATUS_BY_CRITERIAS.collect {|criteria| [l("field_#{criteria}".to_sym), criteria]}, value) |
|
53 | 75 | end |
|
54 | 76 | end |
@@ -1,39 +1,35 | |||
|
1 | 1 | <% if version.completed? %> |
|
2 | 2 | <p><%= format_date(version.effective_date) %></p> |
|
3 | 3 | <% elsif version.effective_date %> |
|
4 | 4 | <p><strong><%= due_date_distance_in_words(version.effective_date) %></strong> (<%= format_date(version.effective_date) %>)</p> |
|
5 | 5 | <% end %> |
|
6 | 6 | |
|
7 | 7 | <p><%=h version.description %></p> |
|
8 | 8 | <% if version.custom_field_values.any? %> |
|
9 | 9 | <ul> |
|
10 | 10 | <% version.custom_field_values.each do |custom_value| %> |
|
11 | 11 | <% if custom_value.value.present? %> |
|
12 | 12 | <li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li> |
|
13 | 13 | <% end %> |
|
14 | 14 | <% end %> |
|
15 | 15 | </ul> |
|
16 | 16 | <% end %> |
|
17 | 17 | |
|
18 | 18 | <% if version.issues_count > 0 %> |
|
19 | 19 | <%= progress_bar([version.closed_percent, version.completed_percent], |
|
20 | 20 | :width => '40em', :legend => ('%0.0f%' % version.completed_percent)) %> |
|
21 | 21 | <p class="progress-info"> |
|
22 |
<%= link_to(l(:label_x_issues, :count => version.issues_count), |
|
|
23 |
|
|
|
24 | :status_id => '*', :fixed_version_id => version, | |
|
25 | :set_filter => 1)) %> | |
|
26 | | |
|
27 | (<%= link_to_if(version.closed_issues_count > 0, | |
|
28 | l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), | |
|
29 | project_issues_path(version.project, :status_id => 'c', | |
|
30 | :fixed_version_id => version, :set_filter => 1)) %> | |
|
31 | — | |
|
32 | <%= link_to_if(version.open_issues_count > 0, | |
|
33 | l(:label_x_open_issues_abbr, :count => version.open_issues_count), | |
|
34 | project_issues_path(version.project, :status_id => 'o', | |
|
35 | :fixed_version_id => version, :set_filter => 1)) %>) | |
|
22 | <%= link_to(l(:label_x_issues, :count => version.issues_count), | |
|
23 | version_filtered_issues_path(version, :status_id => '*')) %> | |
|
24 | | |
|
25 | (<%= link_to_if(version.closed_issues_count > 0, | |
|
26 | l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), | |
|
27 | version_filtered_issues_path(version, :status_id => 'c')) %> | |
|
28 | — | |
|
29 | <%= link_to_if(version.open_issues_count > 0, | |
|
30 | l(:label_x_open_issues_abbr, :count => version.open_issues_count), | |
|
31 | version_filtered_issues_path(version, :status_id => 'o')) %>) | |
|
36 | 32 | </p> |
|
37 | 33 | <% else %> |
|
38 | 34 | <p class="progress-info"><%= l(:label_roadmap_no_issues) %></p> |
|
39 | 35 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now