summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-12 12:38:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-12 12:38:45 +0000
commit14b09361e4a94e8cb28c6572e98231e282e350c8 (patch)
tree6a92828fac5ed8c9ec07c203cb3d74d78f452cbf
parentcd9923e39165dbd4003ce893ce846bb857f91f35 (diff)
downloadredmine-14b09361e4a94e8cb28c6572e98231e282e350c8.tar.gz
redmine-14b09361e4a94e8cb28c6572e98231e282e350c8.zip
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
-rw-r--r--app/models/time_entry_query.rb2
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/fr.yml1
-rw-r--r--test/functional/timelog_controller_test.rb9
-rw-r--r--test/object_helpers.rb11
5 files changed, 23 insertions, 1 deletions
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!