mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Allow imported time entries to override the selected project with the actual project of their issue (#36823).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21522 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b1e4411c49
commit
5914b0ebc2
@ -105,17 +105,21 @@ class TimeEntryImport < Import
|
||||
end
|
||||
|
||||
attributes = {
|
||||
:project_id => project.id,
|
||||
:activity_id => activity_id,
|
||||
:author_id => user.id,
|
||||
:user_id => user_id,
|
||||
|
||||
:issue_id => row_value(row, 'issue_id'),
|
||||
:spent_on => row_date(row, 'spent_on'),
|
||||
:hours => row_value(row, 'hours'),
|
||||
:comments => row_value(row, 'comments')
|
||||
}
|
||||
|
||||
if issue_id = row_value(row, 'issue_id').presence
|
||||
attributes[:issue_id] = issue_id
|
||||
else
|
||||
attributes[:project_id] = project.id
|
||||
end
|
||||
|
||||
attributes['custom_field_values'] = object.custom_field_values.inject({}) do |h, v|
|
||||
value =
|
||||
case v.custom_field.field_format
|
||||
|
||||
@ -165,6 +165,28 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
||||
assert_equal 2, fourth.user_id
|
||||
end
|
||||
|
||||
def test_imports_timelogs_for_issues_in_other_project
|
||||
import = generate_import
|
||||
import.settings = {
|
||||
'separator' => ';', 'wrapper' => '"', 'encoding' => 'UTF-8',
|
||||
'mapping' => {
|
||||
'project_id' => '3',
|
||||
'activity' => 'value:10',
|
||||
'issue_id' => '1',
|
||||
'spent_on' => '2',
|
||||
'hours' => '3',
|
||||
'comments' => '4',
|
||||
'user' => '7'
|
||||
}
|
||||
}
|
||||
import.save!
|
||||
first, second, third, fourth = new_records(TimeEntry, 4) {import.run}
|
||||
assert_equal 3, first.project_id
|
||||
assert_equal 3, second.project_id
|
||||
assert_equal 1, third.project_id
|
||||
assert_equal 1, fourth.project_id
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def generate_import(fixture_name='import_time_entries.csv')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user