From: Go MAEDA Date: Fri, 24 Feb 2023 04:44:36 +0000 (+0000) Subject: Merged r22112 from trunk to 5.0-stable (#38254). X-Git-Tag: 5.0.5~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ac3826ba21d91033e22ee91313b0d3f7b8da50cf;p=redmine.git 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 --- diff --git a/app/models/time_entry_import.rb b/app/models/time_entry_import.rb index f00b24f61..8e336083a 100644 --- a/app/models/time_entry_import.rb +++ b/app/models/time_entry_import.rb @@ -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 diff --git a/test/unit/time_entry_import_test.rb b/test/unit/time_entry_import_test.rb index 9f2cb6cc2..5ab0c096f 100644 --- a/test/unit/time_entry_import_test.rb +++ b/test/unit/time_entry_import_test.rb @@ -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')