1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-10 19:23:06 +00:00

Merged r22112 from trunk to 5.0-stable (#38254).

git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@22114 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2023-02-24 04:44:36 +00:00
parent 712ec96174
commit ac3826ba21
2 changed files with 28 additions and 0 deletions

View File

@ -85,6 +85,7 @@ class TimeEntryImport < Import
def build_object(row, item)
object = TimeEntry.new
object.author = user
object.project = project
activity_id = nil
if activity

View File

@ -165,6 +165,33 @@ class TimeEntryImportTest < ActiveSupport::TestCase
assert_equal 2, fourth.user_id
end
def test_imports_custom_field_with_user_format
cf = TimeEntryCustomField.create! name: 'User Field', field_format: 'user'
import = generate_import
import.settings = {
'separator' => ';', 'wrapper' => '"', 'encoding' => 'UTF-8',
'mapping' => {
'project_id' => '1',
'activity' => 'value:10',
'issue_id' => '1',
'spent_on' => '2',
'hours' => '3',
'comments' => '4',
'user' => '7',
"cf_#{cf.id}" => '7'
}
}
import.save!
first, second, third, fourth = new_records(TimeEntry, 4) {import.run}
jsmith = User.find_by_login 'jsmith'
dlopper = User.find_by_login 'dlopper'
assert_equal dlopper.id, third.custom_values.where(custom_field: cf.id).first.value.to_i
assert_equal jsmith.id, fourth.custom_values.where(custom_field: cf.id).first.value.to_i
assert_equal jsmith.id, first.custom_values.where(custom_field: cf.id).first.value.to_i
assert_equal jsmith.id, second.custom_values.where(custom_field: cf.id).first.value.to_i
end
protected
def generate_import(fixture_name='import_time_entries.csv')