Fix that spent_time total on the issue list can be wrong (#26471).

git-svn-id: http://svn.redmine.org/redmine/trunk@16839 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2017-07-20 16:51:18 +00:00
parent 3c63273c23
commit cd1ca24a87
2 changed files with 51 additions and 13 deletions

View File

@@ -952,6 +952,22 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_equal hours.sort.reverse, hours
end
def test_index_sort_by_spent_hours_should_sort_by_visible_spent_hours
TimeEntry.delete_all
TimeEntry.generate!(:issue => Issue.generate!(:project_id => 1), :hours => 3)
TimeEntry.generate!(:issue => Issue.generate!(:project_id => 3), :hours => 4)
get :index, :params => {:sort => "spent_hours:desc", :c => ['subject','spent_hours']}
assert_response :success
assert_equal [4.0, 3.0, 0.0], issues_in_list.map(&:spent_hours)[0..2]
Project.find(3).disable_module!(:time_tracking)
get :index, :params => {:sort => "spent_hours:desc", :c => ['subject','spent_hours']}
assert_response :success
assert_equal [3.0, 0.0, 0.0], issues_in_list.map(&:spent_hours)[0..2]
end
def test_index_sort_by_total_spent_hours
get :index, :params => {
:sort => 'total_spent_hours:desc'
@@ -1390,6 +1406,22 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select ".total-for-cf-#{field.id} span.value", :text => '9'
end
def test_index_with_spent_time_total_should_sum_visible_spent_time_only
TimeEntry.delete_all
TimeEntry.generate!(:issue => Issue.generate!(:project_id => 1), :hours => 3)
TimeEntry.generate!(:issue => Issue.generate!(:project_id => 3), :hours => 4)
get :index, :params => {:t => ["spent_hours"]}
assert_response :success
assert_select ".total-for-spent-hours span.value", :text => '7.00'
Project.find(3).disable_module!(:time_tracking)
get :index, :params => {:t => ["spent_hours"]}
assert_response :success
assert_select ".total-for-spent-hours span.value", :text => '3.00'
end
def test_index_totals_should_default_to_settings
with_settings :issue_list_default_totals => ['estimated_hours'] do
get :index