]> source.dussan.org Git - redmine.git/commitdiff
Merged r16999 and r17000 (#26667).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Oct 2017 11:56:05 +0000 (11:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Oct 2017 11:56:05 +0000 (11:56 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@17001 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index f432fdbcc05cf7fd6732eb3ec24c63c3845ab653..4092efce67b3d32440e9b0bc6e03c83d67a1d2cd 100644 (file)
@@ -63,7 +63,7 @@ class TimeEntryQuery < Query
     add_available_filter("issue.fixed_version_id",
       :type => :list,
       :name => l("label_attribute_of_issue", :name => l(:field_fixed_version)),
-      :values => lambda { fixed_version_values }) if project
+      :values => lambda { fixed_version_values })
 
     add_available_filter("user_id",
       :type => :list_optional, :values => lambda { author_values }
@@ -159,7 +159,7 @@ class TimeEntryQuery < Query
   end
 
   def sql_for_issue_fixed_version_id_field(field, operator, value)
-    issue_ids = Issue.where(:fixed_version_id => value.first.to_i).pluck(:id)
+    issue_ids = Issue.where(:fixed_version_id => value.map(&:to_i)).pluck(:id)
     case operator
     when "="
       if issue_ids.any?
index 6f3e3f664730a8b903079332a52b97ebe144a574..0e4e64696928773722c8760f93e29e11a4ecf9c1 100644 (file)
@@ -556,6 +556,20 @@ class QueriesControllerTest < Redmine::ControllerTest
     assert_include ["eCookbook - 2.0", "3", "open"], json
   end
 
+  def test_version_filter_time_entries_with_project_id_should_return_filter_values
+    @request.session[:user_id] = 2
+    get :filter, :params => {
+        :project_id => 1,
+        :type => 'TimeEntryQuery',
+        :name => 'issue.fixed_version_id'
+      }
+
+    assert_response :success
+    assert_equal 'application/json', response.content_type
+    json = ActiveSupport::JSON.decode(response.body)
+    assert_include ["eCookbook - 2.0", "3", "open"], json
+  end
+
   def test_filter_without_project_id_should_return_filter_values
     @request.session[:user_id] = 2
     get :filter, :params => {
index 8d3804e5e961e79351d0c6566e1c41a4df6d4335..a0b3fad62de0df7c43d2b62a45417ddf0574e532 100644 (file)
@@ -791,6 +791,27 @@ class TimelogControllerTest < Redmine::ControllerTest
     assert_select '.total-for-hours', :text => 'Hours: 5.00'
   end
 
+  def test_index_at_project_level_with_multiple_issue_fixed_version_ids
+    version = Version.generate!(:project_id => 1)
+    version2 = Version.generate!(:project_id => 1)
+    issue = Issue.generate!(:project_id => 1, :fixed_version => version)
+    issue2 = Issue.generate!(:project_id => 1, :fixed_version => version2)
+    TimeEntry.generate!(:issue => issue, :hours => 2)
+    TimeEntry.generate!(:issue => issue2, :hours => 3)
+    @request.session[:user_id] = 2
+
+    get :index, :params => {
+      :project_id => 'ecookbook',
+      :f => ['issue.fixed_version_id'],
+      :op => {'issue.fixed_version_id' => '='},
+      :v => {'issue.fixed_version_id' => [version.id.to_s,version2.id.to_s]}
+    }
+    assert_response :success
+
+    assert_select 'tr.time-entry', 2
+    assert_select '.total-for-hours', :text => 'Hours: 5.00'
+  end
+
   def test_index_at_project_level_with_date_range
     get :index, :params => {
       :project_id => 'ecookbook',