Defect #33281 » 33281-v2.patch
| app/models/project_query.rb | ||
|---|---|---|
| 69 | 69 |
def available_columns |
| 70 | 70 |
return @available_columns if @available_columns |
| 71 | 71 |
@available_columns = self.class.available_columns.dup |
| 72 |
@available_columns += ProjectCustomField.visible.
|
|
| 72 |
@available_columns += project_custom_fields.visible.
|
|
| 73 | 73 |
map {|cf| QueryCustomFieldColumn.new(cf) }
|
| 74 | 74 |
@available_columns |
| 75 | 75 |
end |
| app/models/query.rb | ||
|---|---|---|
| 609 | 609 |
if project |
| 610 | 610 |
project.rolled_up_custom_fields |
| 611 | 611 |
else |
| 612 |
IssueCustomField.all
|
|
| 612 |
IssueCustomField.sorted
|
|
| 613 | 613 |
end |
| 614 | 614 |
end |
| 615 | 615 | |
| 616 | 616 |
# Returns a scope of project custom fields that are available as columns or filters |
| 617 | 617 |
def project_custom_fields |
| 618 |
ProjectCustomField.all
|
|
| 618 |
ProjectCustomField.sorted
|
|
| 619 | 619 |
end |
| 620 | 620 | |
| 621 | 621 |
# Returns a scope of project statuses that are available as columns or filters |
| app/models/time_entry_query.rb | ||
|---|---|---|
| 113 | 113 |
map {|cf| QueryCustomFieldColumn.new(cf) }
|
| 114 | 114 |
@available_columns += issue_custom_fields.visible. |
| 115 | 115 |
map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf, :totalable => false) }
|
| 116 |
@available_columns += ProjectCustomField.visible.
|
|
| 116 |
@available_columns += project_custom_fields.visible.
|
|
| 117 | 117 |
map {|cf| QueryAssociationCustomFieldColumn.new(:project, cf) }
|
| 118 | 118 |
@available_columns |
| 119 | 119 |
end |
| test/unit/query_test.rb | ||
|---|---|---|
| 1802 | 1802 |
assert_include "cf_#{field.id}".to_sym, q.available_totalable_columns.map(&:name)
|
| 1803 | 1803 |
end |
| 1804 | 1804 | |
| 1805 |
def test_available_totalable_columns_should_sort_in_position_order_for_custom_field |
|
| 1806 |
ProjectCustomField.delete_all |
|
| 1807 |
cf_pos3 = ProjectCustomField.generate!(:position => 3, :is_for_all => true, :field_format => 'int') |
|
| 1808 |
cf_pos4 = ProjectCustomField.generate!(:position => 4, :is_for_all => true, :field_format => 'float') |
|
| 1809 |
cf_pos1 = ProjectCustomField.generate!(:position => 1, :is_for_all => true, :field_format => 'float') |
|
| 1810 |
cf_pos2 = ProjectCustomField.generate!(:position => 2, :is_for_all => true, :field_format => 'int') |
|
| 1811 |
q = ProjectQuery.new |
|
| 1812 |
custom_field_columns = q.available_totalable_columns.select{|column| column.is_a?(QueryCustomFieldColumn)}
|
|
| 1813 |
assert_equal [cf_pos1, cf_pos2, cf_pos3, cf_pos4], custom_field_columns.collect(&:custom_field) |
|
| 1814 | ||
| 1815 |
q = TimeEntryQuery.new |
|
| 1816 |
custom_field_columns = q.available_totalable_columns.select{|column| column.is_a?(QueryCustomFieldColumn)}
|
|
| 1817 |
assert_equal [cf_pos1, cf_pos2, cf_pos3, cf_pos4], custom_field_columns.collect(&:custom_field) |
|
| 1818 | ||
| 1819 |
IssueCustomField.delete_all |
|
| 1820 |
cf_pos3 = IssueCustomField.generate!(:position => 3, :is_for_all => true, :field_format => 'int') |
|
| 1821 |
cf_pos4 = IssueCustomField.generate!(:position => 4, :is_for_all => true, :field_format => 'float') |
|
| 1822 |
cf_pos1 = IssueCustomField.generate!(:position => 1, :is_for_all => true, :field_format => 'float') |
|
| 1823 |
cf_pos2 = IssueCustomField.generate!(:position => 2, :is_for_all => true, :field_format => 'int') |
|
| 1824 |
q = IssueQuery.new |
|
| 1825 |
custom_field_columns = q.available_totalable_columns.select{|column| column.is_a?(QueryCustomFieldColumn)}
|
|
| 1826 |
assert_equal [cf_pos1, cf_pos2, cf_pos3, cf_pos4], custom_field_columns.collect(&:custom_field) |
|
| 1827 |
end |
|
| 1828 | ||
| 1805 | 1829 |
def test_total_for_estimated_hours |
| 1806 | 1830 |
Issue.delete_all |
| 1807 | 1831 |
Issue.generate!(:estimated_hours => 5.5) |