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
This commit is contained in:
Jean-Philippe Lang 2013-01-12 12:38:45 +00:00
parent cd9923e391
commit 14b09361e4
5 changed files with 23 additions and 1 deletions

View File

@ -88,7 +88,7 @@ class TimeEntryQuery < Query
} unless activities.empty? } unless activities.empty?
add_custom_fields_filters(TimeEntryCustomField.where(:is_filter => true).all) 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| @available_filters.each do |field, options|
options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, '')) options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))

View File

@ -875,6 +875,7 @@ en:
label_readonly: Read-only label_readonly: Read-only
label_required: Required label_required: Required
label_attribute_of_project: "Project's %{name}" label_attribute_of_project: "Project's %{name}"
label_attribute_of_issue: "Issue's %{name}"
label_attribute_of_author: "Author's %{name}" label_attribute_of_author: "Author's %{name}"
label_attribute_of_assigned_to: "Assignee's %{name}" label_attribute_of_assigned_to: "Assignee's %{name}"
label_attribute_of_user: "User's %{name}" label_attribute_of_user: "User's %{name}"

View File

@ -851,6 +851,7 @@ fr:
label_readonly: Lecture label_readonly: Lecture
label_required: Obligatoire label_required: Obligatoire
label_attribute_of_project: "%{name} du projet" 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_author: "%{name} de l'auteur"
label_attribute_of_assigned_to: "%{name} de l'assigné" label_attribute_of_assigned_to: "%{name} de l'assigné"
label_attribute_of_user: "%{name} de l'utilisateur" label_attribute_of_user: "%{name} de l'utilisateur"

View File

@ -519,6 +519,15 @@ class TimelogControllerTest < ActionController::TestCase
assert_equal [t3, t1, t2], assigns(:entries) assert_equal [t3, t1, t2], assigns(:entries)
end 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 def test_index_atom_feed
get :index, :project_id => 1, :format => 'atom' get :index, :project_id => 1, :format => 'atom'
assert_response :success assert_response :success

View File

@ -98,6 +98,17 @@ module ObjectHelpers
version version
end 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={}) def AuthSource.generate!(attributes={})
@generated_auth_source_name ||= 'Auth 0' @generated_auth_source_name ||= 'Auth 0'
@generated_auth_source_name.succ! @generated_auth_source_name.succ!