From d7e0394eb5bf7159b73e688aa64591765f7fe12d Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 9 Aug 2019 09:37:07 +0000 Subject: Merged r18356 from trunk to 4.0-stable (#31778). git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18359 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/issue_subtasking_test.rb | 5 ++++- test/unit/query_test.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index 00d64a052..c54586d70 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -332,7 +332,7 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end end - def test_parent_total_estimated_hours_should_be_sum_of_descendants + def test_parent_total_estimated_hours_should_be_sum_of_visible_descendants parent = Issue.generate! parent.generate_child!(:estimated_hours => nil) assert_equal 0, parent.reload.total_estimated_hours @@ -340,6 +340,9 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert_equal 5, parent.reload.total_estimated_hours parent.generate_child!(:estimated_hours => 7) assert_equal 12, parent.reload.total_estimated_hours + + parent.generate_child!(:estimated_hours => 9, :is_private => true) + assert_equal 12, parent.reload.total_estimated_hours end def test_open_issue_with_closed_parent_should_not_validate diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index b1a7002db..094af4230 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -1558,6 +1558,39 @@ class QueryTest < ActiveSupport::TestCase assert_equal values.sort, values end + def test_sort_by_total_for_estimated_hours + # Prepare issues + parent = issues(:issues_001) + child = issues(:issues_002) + private_child = issues(:issues_003) + other = issues(:issues_007) + + User.current = users(:users_001) + + parent.safe_attributes = {:estimated_hours => 1} + child.safe_attributes = {:estimated_hours => 2, :parent_issue_id => 1} + private_child.safe_attributes = {:estimated_hours => 4, :parent_issue_id => 1, :is_private => true} + other.safe_attributes = {:estimated_hours => 5} + + [parent, child, private_child, other].each(&:save!) + + + q = IssueQuery.new( + :name => '_', + :filters => { 'issue_id' => {:operator => '=', :values => ['1,7']} }, + :sort_criteria => [['total_estimated_hours', 'asc']] + ) + + # With private_child, `parent' is "bigger" than `other' + ids = q.issue_ids + assert_equal [7, 1], ids, "Private issue was not used to calculate sort order" + + # Without the invisible private_child, `other' is "bigger" than `parent' + User.current = User.anonymous + ids = q.issue_ids + assert_equal [1, 7], ids, "Private issue was used to calculate sort order" + end + def test_set_totalable_names q = IssueQuery.new q.totalable_names = ['estimated_hours', :spent_hours, ''] -- cgit v1.2.3