]> source.dussan.org Git - redmine.git/commitdiff
Merged r21371 from trunk to 4.2-stable (#20018).
authorGo MAEDA <maeda@farend.jp>
Sat, 29 Jan 2022 06:19:31 +0000 (06:19 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 29 Jan 2022 06:19:31 +0000 (06:19 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@21388 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/helpers/time_report.rb
test/functional/timelog_report_test.rb

index 531026f633fb81f259cc8410db8fa5c378cf5055..f2eb281165ccd5a42aa5e4a9de99ef2b8b45a96c 100644 (file)
@@ -123,7 +123,7 @@ module Redmine
           'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
                         :klass => Tracker,
                         :label => :label_tracker},
-          'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
+          'activity' => {:sql => "COALESCE(#{TimeEntryActivity.table_name}.parent_id, #{TimeEntryActivity.table_name}.id)",
                          :klass => TimeEntryActivity,
                          :label => :field_activity},
           'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
index 5b56f1ea96afd74cfb2bf48c572b4e4b38601942..bfdfdae01462330b3b9b354044c29b5496a1424a 100644 (file)
@@ -224,6 +224,19 @@ class TimelogReportTest < Redmine::ControllerTest
     assert_select 'td', :text => 'New'
   end
 
+  def test_report_activity_criterion_should_aggregate_system_activity_and_project_activity
+    activity = TimeEntryActivity.create!(:name => 'Design', :parent_id => 9, :project_id => 3)
+    TimeEntry.generate!(:project_id => 3, :issue_id => 5, :activity_id => activity.id, :spent_on => '2007-05-23', :hours => 10.0)
+
+    get :report, :params => {:project_id => 1, :criteria => ['activity']}
+    assert_response :success
+
+    assert_select 'tr.last-level:first' do
+      assert_select 'td.name', :text => 'Design'
+      assert_select 'td.hours:last', :text => '165.25'
+    end
+  end
+
   def test_report_all_projects_csv_export
     get :report, :params => {
       :columns => 'month',