Project

General

Profile

Feature #36823 » 0001-allow-imported-time-entries-to-override-the-selected.patch

Jens Krämer, 2022-03-22 12:04

View differences:

app/models/time_entry_import.rb
end
attributes = {
:project_id => project.id,
:activity_id => activity_id,
:author_id => user.id,
:user_id => user_id,
:issue_id => row_value(row, 'issue_id'),
:spent_on => row_date(row, 'spent_on'),
:hours => row_value(row, 'hours'),
:comments => row_value(row, 'comments')
}
if issue_id = row_value(row, 'issue_id').presence
attributes[:issue_id] = issue_id
else
attributes[:project_id] = project.id
end
attributes['custom_field_values'] = object.custom_field_values.inject({}) do |h, v|
value =
case v.custom_field.field_format
test/unit/time_entry_import_test.rb
assert_equal 2, fourth.user_id
end
def test_imports_timelogs_for_issues_in_other_project
import = generate_import
import.settings = {
'separator' => ';', 'wrapper' => '"', 'encoding' => 'UTF-8',
'mapping' => {
'project_id' => '3',
'activity' => 'value:10',
'issue_id' => '1',
'spent_on' => '2',
'hours' => '3',
'comments' => '4',
'user' => '7'
}
}
import.save!
first, second, third, fourth = new_records(TimeEntry, 4) {import.run}
assert_equal 3, first.project_id
assert_equal 3, second.project_id
assert_equal 1, third.project_id
assert_equal 1, fourth.project_id
end
protected
def generate_import(fixture_name='import_time_entries.csv')
    (1-1/1)