]> source.dussan.org Git - redmine.git/commitdiff
Merged r21423 to 4.2-stable (#36248).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 20 Feb 2022 18:53:58 +0000 (18:53 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 20 Feb 2022 18:53:58 +0000 (18:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@21425 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 11128cfcd6e670d215651d7b3616c18d3aabfe09..5fd4790893cd694e8cfab7b6bc9e435675d88d36 100644 (file)
@@ -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",
index a7a87c2b970fcb338761a88034c75dfa6502a91f..ef1de2eb6b21001e20a3f00c2947ad32a125cf43 100644 (file)
@@ -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