summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-02-16 00:31:29 +0000
committerGo MAEDA <maeda@farend.jp>2023-02-16 00:31:29 +0000
commita3ca8ba677991c58140a8cfd6590ae15352cee5d (patch)
treedec42c9368dd4bbd8049b1dcc5075c18cbf247cc /test
parentdc50caf1bed6f76ac9fdc5248c8c8ed24d36fa59 (diff)
downloadredmine-a3ca8ba677991c58140a8cfd6590ae15352cee5d.tar.gz
redmine-a3ca8ba677991c58140a8cfd6590ae15352cee5d.zip
Time Entry Import fails to import custom fields with "User" format (#38254).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@22112 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/time_entry_import_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/time_entry_import_test.rb b/test/unit/time_entry_import_test.rb
index 3766f12cb..f2feb275c 100644
--- a/test/unit/time_entry_import_test.rb
+++ b/test/unit/time_entry_import_test.rb
@@ -187,6 +187,33 @@ class TimeEntryImportTest < ActiveSupport::TestCase
assert_equal 1, fourth.project_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')