]> source.dussan.org Git - redmine.git/commitdiff
Fixed that total estimated time column is shown even when estimated time field is...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 08:30:15 +0000 (08:30 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 08:30:15 +0000 (08:30 +0000)
Patch by Felix Schäfer and Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@18743 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
test/unit/query_test.rb

index 348845a43d5001ce75c91529b25dd1e876a33f4a..b134cec214712ed510475546a2bad2e73d3a515e 100644 (file)
@@ -247,6 +247,7 @@ class IssueQuery < Query
     end
 
     disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.sub(/_id$/, '')}
+    disabled_fields << "total_estimated_hours" if disabled_fields.include?("estimated_hours")
     @available_columns.reject! {|column|
       disabled_fields.include?(column.name.to_s)
     }
index 7888a499343fd2f6b56bb796f62c577c3d2933d4..db0d4c884a752e2649fc9386d4f925a76f6e7b67 100644 (file)
@@ -2085,6 +2085,25 @@ class QueryTest < ActiveSupport::TestCase
     end
   end
 
+  def test_available_columns_should_not_include_total_estimated_hours_when_trackers_disabled_estimated_hours
+    Tracker.visible.each do |tracker|
+      tracker.core_fields = tracker.core_fields.reject{|field| field == 'estimated_hours'}
+      tracker.save!
+    end
+    query = IssueQuery.new
+    available_columns = query.available_columns.map(&:name)
+    assert_not_include :estimated_hours, available_columns
+    assert_not_include :total_estimated_hours, available_columns
+
+    tracker = Tracker.visible.first
+    tracker.core_fields = ['estimated_hours']
+    tracker.save!
+    query = IssueQuery.new
+    available_columns = query.available_columns.map(&:name)
+    assert_include :estimated_hours, available_columns
+    assert_include :total_estimated_hours, available_columns
+  end
+
   def setup_member_of_group
     Group.destroy_all # No fixtures
     @user_in_group = User.generate!