From f909a8c006d01e8b500ef8ffc9963bdf81662faf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 30 Oct 2012 14:24:33 +0000 Subject: [PATCH] Issues by Category should show tasks without category (#8106). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10771 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/versions_helper.rb | 3 ++- app/views/versions/_issue_counts.html.erb | 11 +++++------ test/functional/versions_controller_test.rb | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 91dec8e91..91082380c 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -44,7 +44,8 @@ module VersionsHelper rescue ActiveRecord::RecordNotFound # When grouping by an association, Rails throws this exception if there's no result (bug) end - counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} + # Sort with nil keys in last position + 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])}} max = counts.collect {|c| c[:total]}.max render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max} diff --git a/app/views/versions/_issue_counts.html.erb b/app/views/versions/_issue_counts.html.erb index d4b33255c..50f174d08 100644 --- a/app/views/versions/_issue_counts.html.erb +++ b/app/views/versions/_issue_counts.html.erb @@ -14,12 +14,11 @@ <% counts.each do |count| %> - <%= link_to h(count[:group]), {:controller => 'issues', - :action => 'index', - :project_id => version.project, - :set_filter => 1, - :status_id => '*', - :fixed_version_id => version}.merge("#{criteria}_id".to_sym => count[:group]) %> + <% if count[:group] -%> + <%= link_to(h(count[:group]), project_issues_path(version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => version, "#{criteria}_id" => count[:group])) %> + <% else -%> + <%= link_to(l(:label_none), project_issues_path(version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => version, "#{criteria}_id" => "!*")) %> + <% end %> <%= progress_bar((count[:closed].to_f / count[:total])*100, diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb index c6906ca5b..8379585d5 100644 --- a/test/functional/versions_controller_test.rb +++ b/test/functional/versions_controller_test.rb @@ -22,7 +22,7 @@ require 'versions_controller' class VersionsController; def rescue_action(e) raise e end; end class VersionsControllerTest < ActionController::TestCase - fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules, :issue_statuses + fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules, :issue_statuses, :issue_categories def setup @controller = VersionsController.new @@ -103,6 +103,19 @@ class VersionsControllerTest < ActionController::TestCase assert_tag :tag => 'h2', :content => /1.0/ end + def test_show_should_display_nil_counts + with_settings :default_language => 'en' do + get :show, :id => 2, :status_by => 'category' + assert_response :success + assert_select 'div#status_by' do + assert_select 'select[name=status_by]' do + assert_select 'option[value=category][selected=selected]' + end + assert_select 'a', :text => 'none' + end + end + end + def test_new @request.session[:user_id] = 2 get :new, :project_id => '1'