[#5482] Fix counts when grouping by contracts in the issues list

This commit is contained in:
Eric Davis
2011-02-22 10:58:19 -08:00
parent 3384dd3dbd
commit 496c6bada7
3 changed files with 11 additions and 3 deletions
+5 -1
View File
@@ -92,8 +92,12 @@ Dispatcher.to_prepare :redmine_contracts do
Query.add_available_column(QueryColumn.new(:deliverable, :sortable => "#{Deliverable.table_name}.title", :groupable => 'deliverable'))
end
# Hack in order to get the associated contract to be grouped by name
# * Proxy method Issue#contract_name
# * Naming Query column contract_name
# * Grouping by 'contracts.name'
unless Query.available_columns.collect(&:name).include?(:contract_name)
Query.add_available_column(QueryColumn.new(:contract_name, :sortable => "#{Contract.table_name}.name", :groupable => 'contract_id'))
Query.add_available_column(QueryColumn.new(:contract_name, :sortable => "#{Contract.table_name}.name", :groupable => 'contracts.name'))
end
end
+5 -1
View File
@@ -10,7 +10,11 @@ module RedmineContracts
belongs_to :deliverable
delegate :title, :to => :deliverable, :prefix => true, :allow_nil => true
delegate :contract_name, :to => :deliverable, :allow_nil => true
delegate :contract, :to => :deliverable, :allow_nil => true
def contract_name
contract.try(:name)
end
end
end
+1 -1
View File
@@ -62,7 +62,7 @@ class IssueFilteringTest < ActionController::IntegrationTest
assert_select "span.count", "(1)"
end
assert_select "td", :text => Regexp.new(@contract.name) do
assert_select "span.count", "()"
assert_select "span.count", "(1)"
end
end