]> source.dussan.org Git - redmine.git/commitdiff
Merged r18743 to 3.4-stable (#31779).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 08:37:25 +0000 (08:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 08:37:25 +0000 (08:37 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@18745 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 668941bdd42d980dc77dd91e23fc642f2a88d9dd..c8336078a182dbedb5bb59a07937e54a2f2b6b83 100644 (file)
@@ -221,6 +221,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 0b0de108c0ccadd1010bc666154a601a34999df8..ac2b4a00ebd5eaf9af306b8de6091b08a105741a 100644 (file)
@@ -1952,6 +1952,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!