mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 17:26:06 +01:00
Don't use User.current in TimeEntryImport model but #user instead (#32774).
git-svn-id: http://svn.redmine.org/redmine/trunk@19678 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -94,7 +94,7 @@ class TimeEntryImport < Import
|
||||
end
|
||||
|
||||
user_id = nil
|
||||
if User.current.allowed_to?(:log_time_for_other_users, project)
|
||||
if user.allowed_to?(:log_time_for_other_users, project)
|
||||
if user_value
|
||||
user_id = user_value
|
||||
elsif user_name = row_value(row, 'user')
|
||||
@@ -107,6 +107,7 @@ class TimeEntryImport < Import
|
||||
attributes = {
|
||||
:project_id => project.id,
|
||||
:activity_id => activity_id,
|
||||
:author_id => user.id,
|
||||
:user_id => user_id,
|
||||
|
||||
:issue_id => row_value(row, 'issue_id'),
|
||||
|
||||
@@ -127,7 +127,8 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_maps_user_id_for_user_with_permissions
|
||||
User.current = User.find(1)
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
|
||||
import = generate_import_with_mapping
|
||||
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
||||
|
||||
@@ -138,16 +139,17 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_maps_user_to_column_value
|
||||
User.current = User.find(1)
|
||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('user' => 'value:1')
|
||||
import.mapping.merge!('user' => 'value:3')
|
||||
import.save!
|
||||
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
||||
|
||||
assert_equal 1, first.user_id
|
||||
assert_equal 1, second.user_id
|
||||
assert_equal 1, third.user_id
|
||||
assert_equal 1, fourth.user_id
|
||||
assert_equal 3, first.user_id
|
||||
assert_equal 3, second.user_id
|
||||
assert_equal 3, third.user_id
|
||||
assert_equal 3, fourth.user_id
|
||||
end
|
||||
|
||||
def test_maps_user_id_for_user_without_permissions
|
||||
|
||||
Reference in New Issue
Block a user