summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-02-24 04:44:36 +0000
committerGo MAEDA <maeda@farend.jp>2023-02-24 04:44:36 +0000
commitac3826ba21d91033e22ee91313b0d3f7b8da50cf (patch)
tree7a1e06edfe67eb14432f03569c8f5290a6d7e1a3
parent712ec961748e130ff1f7d279cd7b350a3f460b7b (diff)
downloadredmine-ac3826ba21d91033e22ee91313b0d3f7b8da50cf.tar.gz
redmine-ac3826ba21d91033e22ee91313b0d3f7b8da50cf.zip
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
-rw-r--r--app/models/time_entry_import.rb1
-rw-r--r--test/unit/time_entry_import_test.rb27
2 files changed, 28 insertions, 0 deletions
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')