]> source.dussan.org Git - redmine.git/commitdiff
Adds "Target Version" column to the list of "Available columns" in "Spent time" tab...
authorGo MAEDA <maeda@farend.jp>
Sun, 10 Nov 2019 00:42:30 +0000 (00:42 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 10 Nov 2019 00:42:30 +0000 (00:42 +0000)
Patch by Marius BALTEANU.

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

app/models/time_entry_query.rb
test/functional/timelog_controller_test.rb

index f2d0b7684db0b15823e79ab89c87dfb56c912699..a51601620a7c7336c10b40d6941b31696dea8bd8 100644 (file)
@@ -34,6 +34,7 @@ class TimeEntryQuery < Query
     QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.position"),
     QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.position"),
     QueryAssociationColumn.new(:issue, :category, :caption => :field_category, :sortable => "#{IssueCategory.table_name}.name"),
+    QueryAssociationColumn.new(:issue, :fixed_version, :caption => :field_fixed_version, :sortable => Version.fields_for_order_statement),
     QueryColumn.new(:comments),
     QueryColumn.new(:hours, :sortable => "#{TimeEntry.table_name}.hours", :totalable => true),
   ]
@@ -251,6 +252,9 @@ class TimeEntryQuery < Query
       if order_options.include?('issue_categories')
         joins << "LEFT OUTER JOIN #{IssueCategory.table_name} ON #{IssueCategory.table_name}.id = #{Issue.table_name}.category_id"
       end
+      if order_options.include?('versions')
+        joins << "LEFT OUTER JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Issue.table_name}.fixed_version_id"
+      end
     end
 
     joins.compact!
index 152912bd90ecf5e7e7186767457f4587aca46105..f23a10c10fedc3c3e0ea57d2e97eb0d9afaf93b4 100644 (file)
@@ -1193,6 +1193,20 @@ class TimelogControllerTest < Redmine::ControllerTest
     assert_select 'td.issue-category', :text => 'Printing'
   end
 
+  def test_index_with_issue_fixed_version_column
+    issue = Issue.find(1)
+    issue.fixed_version = Version.find(3)
+    issue.save!
+
+    get :index, :params => {
+      :project_id => 'ecookbook',
+      :c => %w(project spent_on issue comments hours issue.fixed_version)
+    }
+
+    assert_response :success
+    assert_select 'td.issue-fixed_version', :text => '2.0'
+  end
+
   def test_index_with_author_filter
     get :index, :params => {
       :project_id => 'ecookbook',
@@ -1230,6 +1244,25 @@ class TimelogControllerTest < Redmine::ControllerTest
     assert_equal ['Printing', 'Printing', 'Recipes'], values
   end
 
+  def test_index_with_issue_fixed_version_sort
+    issue = Issue.find(1)
+    issue.fixed_version = Version.find(3)
+    issue.save!
+
+    TimeEntry.generate!(:issue => Issue.find(12))
+
+    get :index, :params => {
+      :project_id => 'ecookbook',
+      :c => ["hours", 'issue.fixed_version'],
+      :sort => 'issue.fixed_version'
+    }
+
+    assert_response :success
+    # Make sure that values are properly sorted
+    values = css_select("td.issue-fixed_version").map(&:text).reject(&:blank?)
+    assert_equal ['1.0', '2.0', '2.0'], values
+  end
+
   def test_index_with_filter_on_issue_custom_field
     issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
     entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)