]> source.dussan.org Git - redmine.git/commitdiff
Adds issue custom fields to time entries filters (#10191).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Jan 2013 12:38:45 +0000 (12:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Jan 2013 12:38:45 +0000 (12:38 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11171 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry_query.rb
config/locales/en.yml
config/locales/fr.yml
test/functional/timelog_controller_test.rb
test/object_helpers.rb

index d3a5a84efd641d8a4e41fa38fd230f168363ed1f..9ffa5f15de02f8afecda0744ee459bf07c999ae0 100644 (file)
@@ -88,7 +88,7 @@ class TimeEntryQuery < Query
     } unless activities.empty?
 
     add_custom_fields_filters(TimeEntryCustomField.where(:is_filter => true).all)
-    add_associations_custom_fields_filters :project, :user
+    add_associations_custom_fields_filters :project, :issue, :user
 
     @available_filters.each do |field, options|
       options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
index c63b3bc3ae21f7241ec8686fb35d4147414fce9f..fa3164203e029530c2ef90c7e21613e94772e2bd 100644 (file)
@@ -875,6 +875,7 @@ en:
   label_readonly: Read-only
   label_required: Required
   label_attribute_of_project: "Project's %{name}"
+  label_attribute_of_issue: "Issue's %{name}"
   label_attribute_of_author: "Author's %{name}"
   label_attribute_of_assigned_to: "Assignee's %{name}"
   label_attribute_of_user: "User's %{name}"
index 8229a43adaed91b3255648239cc00d8bfd60964e..ee4b21d9b839dc1997412732873079cd1b12825f 100644 (file)
@@ -851,6 +851,7 @@ fr:
   label_readonly: Lecture
   label_required: Obligatoire
   label_attribute_of_project: "%{name} du projet"
+  label_attribute_of_issue: "%{name} de la demande"
   label_attribute_of_author: "%{name} de l'auteur"
   label_attribute_of_assigned_to: "%{name} de l'assigné"
   label_attribute_of_user: "%{name} de l'utilisateur"
index 5038a09d6f5760764f51c77133aef20bba3bad35..cb81a41ad4e4af18d94f9f923824f90ae43f2f8c 100644 (file)
@@ -519,6 +519,15 @@ class TimelogControllerTest < ActionController::TestCase
     assert_equal [t3, t1, t2], assigns(:entries)
   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)
+
+    get :index, :f => ['issue.cf_2'], :op => {'issue.cf_2' => '='}, :v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
+    assert_response :success
+    assert_equal [entry], assigns(:entries)
+  end
+
   def test_index_atom_feed
     get :index, :project_id => 1, :format => 'atom'
     assert_response :success
index 575c9f2338698a2930c9b382d4dc154175337a35..254b6040e4400cc667adf4414fdf19c744b4348d 100644 (file)
@@ -98,6 +98,17 @@ module ObjectHelpers
     version
   end
 
+  def TimeEntry.generate!(attributes={})
+    entry = TimeEntry.new(attributes)
+    entry.user ||= User.find(2)
+    entry.issue ||= Issue.find(1)
+    entry.project ||= entry.issue.project
+    entry.activity ||= TimeEntryActivity.first
+    entry.spent_on ||= Date.today
+    entry.save!
+    entry
+  end
+
   def AuthSource.generate!(attributes={})
     @generated_auth_source_name ||= 'Auth 0'
     @generated_auth_source_name.succ!