summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-02-19 14:31:39 +0000
committerGo MAEDA <maeda@farend.jp>2020-02-19 14:31:39 +0000
commit4d341f0f143c0327c85ac67da0b984c453cee144 (patch)
tree9793aa2b7fa7195f56b49c7cccad66e9972d00ad
parent5873af5ae32cf901071738efb8decadc0e9428c0 (diff)
downloadredmine-4d341f0f143c0327c85ac67da0b984c453cee144.tar.gz
redmine-4d341f0f143c0327c85ac67da0b984c453cee144.zip
Use 'user' as internal field instead of user_id because the column accepts also user login as value, not only the id (#22913).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@19523 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/time_entry_import.rb4
-rw-r--r--app/views/imports/_time_entries_fields_mapping.html.erb4
-rw-r--r--test/fixtures/files/import_time_entries.csv2
-rw-r--r--test/functional/imports_controller_test.rb2
-rw-r--r--test/unit/time_entry_import_test.rb4
5 files changed, 8 insertions, 8 deletions
diff --git a/app/models/time_entry_import.rb b/app/models/time_entry_import.rb
index 0ac4429f4..fa33b60c5 100644
--- a/app/models/time_entry_import.rb
+++ b/app/models/time_entry_import.rb
@@ -66,7 +66,7 @@ class TimeEntryImport < Import
end
def user_value
- if mapping['user_id'].to_s =~ /\Avalue:(\d+)\z/
+ if mapping['user'].to_s =~ /\Avalue:(\d+)\z/
$1.to_i
end
end
@@ -88,7 +88,7 @@ class TimeEntryImport < Import
if User.current.allowed_to?(:log_time_for_other_users, project)
if user_value
user_id = user_value
- elsif user_name = row_value(row, 'user_id')
+ elsif user_name = row_value(row, 'user')
user_id = Principal.detect_by_keyword(allowed_target_users, user_name).try(:id)
end
else
diff --git a/app/views/imports/_time_entries_fields_mapping.html.erb b/app/views/imports/_time_entries_fields_mapping.html.erb
index 1b4f7a0e4..c455d3b91 100644
--- a/app/views/imports/_time_entries_fields_mapping.html.erb
+++ b/app/views/imports/_time_entries_fields_mapping.html.erb
@@ -14,8 +14,8 @@
<div class="splitcontentleft">
<% if User.current.allowed_to?(:log_time_for_other_users, @import.project) %>
<p>
- <label for="import_mapping_user_id"><%= l(:field_user) %></label>
- <%= mapping_select_tag @import, 'user_id', :required => true,
+ <label for="import_mapping_user"><%= l(:field_user) %></label>
+ <%= mapping_select_tag @import, 'user', :required => true,
:values => @import.allowed_target_users.map {|u| [u.name, u.id]}, :default_value => "value:#{User.current.id}" %>
</p>
<% end %>
diff --git a/test/fixtures/files/import_time_entries.csv b/test/fixtures/files/import_time_entries.csv
index b89cfdfaa..dfd2abfd6 100644
--- a/test/fixtures/files/import_time_entries.csv
+++ b/test/fixtures/files/import_time_entries.csv
@@ -1,4 +1,4 @@
-row;issue_id;date;hours;comment;activity;overtime;user_id
+row;issue_id;date;hours;comment;activity;overtime;user
1;;2020-01-01;1;Some Design;Design;yes;jsmith@somenet.foo
2;;2020-01-02;2;Some Development;Development;yes;jsmith@somenet.foo
3;1;2020-01-03;3;Some QA;QA;no;dlopper@somenet.foo
diff --git a/test/functional/imports_controller_test.rb b/test/functional/imports_controller_test.rb
index 6b22bb19a..7b5a132fc 100644
--- a/test/functional/imports_controller_test.rb
+++ b/test/functional/imports_controller_test.rb
@@ -202,7 +202,7 @@ class ImportsControllerTest < Redmine::ControllerTest
# 'user_id' field should be available because User#2 has both
# 'import_time_entries' and 'log_time_for_other_users' permissions
- assert_select 'select[name=?]', 'import_settings[mapping][user_id]' do
+ assert_select 'select[name=?]', 'import_settings[mapping][user]' do
# Current user should be the default value
assert_select 'option[value="value:2"][selected]', :text => User.find(2).name
assert_select 'option[value="value:3"]', :text => User.find(3).name
diff --git a/test/unit/time_entry_import_test.rb b/test/unit/time_entry_import_test.rb
index d84de22f4..c974707b0 100644
--- a/test/unit/time_entry_import_test.rb
+++ b/test/unit/time_entry_import_test.rb
@@ -140,7 +140,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase
def test_maps_user_to_column_value
User.current = User.find(1)
import = generate_import_with_mapping
- import.mapping.merge!('user_id' => 'value:1')
+ import.mapping.merge!('user' => 'value:1')
import.save!
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
@@ -185,7 +185,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase
'spent_on' => '2',
'hours' => '3',
'comments' => '4',
- 'user_id' => '7'
+ 'user' => '7'
}
}
import.save!