From 14b09361e4a94e8cb28c6572e98231e282e350c8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 12 Jan 2013 12:38:45 +0000 Subject: [PATCH] Adds issue custom fields to time entries filters (#10191). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11171 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/time_entry_query.rb | 2 +- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + test/functional/timelog_controller_test.rb | 9 +++++++++ test/object_helpers.rb | 11 +++++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb index d3a5a84ef..9ffa5f15d 100644 --- a/app/models/time_entry_query.rb +++ b/app/models/time_entry_query.rb @@ -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$/, '')) diff --git a/config/locales/en.yml b/config/locales/en.yml index c63b3bc3a..fa3164203 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 8229a43ad..ee4b21d9b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -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" diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 5038a09d6..cb81a41ad 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -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 diff --git a/test/object_helpers.rb b/test/object_helpers.rb index 575c9f233..254b6040e 100644 --- a/test/object_helpers.rb +++ b/test/object_helpers.rb @@ -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!