From: Marius Balteanu Date: Sun, 20 Feb 2022 18:50:22 +0000 (+0000) Subject: Fix time entries of sub-projects are not listed when activity is specified in filters... X-Git-Tag: 5.0.0~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a738c2069468282a70932c6db6d5c6b7ba24df4;p=redmine.git Fix time entries of sub-projects are not listed when activity is specified in filters (#36248). Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@21423 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb index 64ba53b6f..3b884820f 100644 --- a/app/models/time_entry_query.rb +++ b/app/models/time_entry_query.rb @@ -88,7 +88,7 @@ class TimeEntryQuery < Query activities = (project ? project.activities : TimeEntryActivity.shared) add_available_filter( "activity_id", - :type => :list, :values => activities.map {|a| [a.name, a.id.to_s]} + :type => :list, :values => activities.map {|a| [a.name, (a.parent_id || a.id).to_s]} ) add_available_filter( "project.status", diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index c6b3fec74..02dba38ad 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -917,4 +917,28 @@ class QueriesControllerTest < Redmine::ControllerTest assert_include ['Dave2 Lopper2', '5', 'locked'], json assert_include ['A Team', '10', 'active'], json end + + def test_activity_filter_should_return_active_and_system_activity_ids + TimeEntryActivity.create!(:name => 'Design', :parent_id => 9, :project_id => 1) + TimeEntryActivity.create!(:name => 'QA', :active => false, :parent_id => 11, :project_id => 1) + TimeEntryActivity.create!(:name => 'Inactive Activity', :active => true, :parent_id => 14, :project_id => 1) + + @request.session[:user_id] = 2 + get( + :filter, + :params => { + :project_id => 1, + :type => 'TimeEntryQuery', + :name => 'activity_id' + } + ) + assert_response :success + assert_equal 'application/json', response.media_type + json = ActiveSupport::JSON.decode(response.body) + + assert_equal 3, json.count + assert_include ["Design", "9"], json + assert_include ["Development", "10"], json + assert_include ["Inactive Activity", "14"], json + end end