diff options
Diffstat (limited to 'app/services/issuable')
-rw-r--r-- | app/services/issuable/clone/base_service.rb | 1 | ||||
-rw-r--r-- | app/services/issuable/common_system_notes_service.rb | 15 | ||||
-rw-r--r-- | app/services/issuable/import_csv/base_service.rb | 16 |
3 files changed, 23 insertions, 9 deletions
diff --git a/app/services/issuable/clone/base_service.rb b/app/services/issuable/clone/base_service.rb index 98c50347719..3c13944cfbc 100644 --- a/app/services/issuable/clone/base_service.rb +++ b/app/services/issuable/clone/base_service.rb @@ -16,6 +16,7 @@ module Issuable # ApplicationRecord.transaction do @new_entity = create_new_entity + @new_entity.system_note_timestamp = nil update_new_entity update_old_entity diff --git a/app/services/issuable/common_system_notes_service.rb b/app/services/issuable/common_system_notes_service.rb index 5cf32ee3e40..db28be864a7 100644 --- a/app/services/issuable/common_system_notes_service.rb +++ b/app/services/issuable/common_system_notes_service.rb @@ -21,7 +21,7 @@ module Issuable create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked') end - create_due_date_note if issuable.previous_changes.include?('due_date') + handle_start_date_or_due_date_change_note create_milestone_change_event(old_milestone) if issuable.previous_changes.include?('milestone_id') create_labels_note(old_labels) if old_labels && issuable.labels != old_labels end @@ -29,6 +29,13 @@ module Issuable private + def handle_start_date_or_due_date_change_note + # Type check needed as some issuables do their own date change handling for date fields other than due_date + change_date_fields = issuable.is_a?(Issue) ? %w[due_date start_date] : %w[due_date] + changed_dates = issuable.previous_changes.slice(*change_date_fields) + create_start_date_or_due_date_note(changed_dates) + end + def handle_time_tracking_note if issuable.previous_changes.include?('time_estimate') create_time_estimate_note @@ -99,8 +106,10 @@ module Issuable .execute end - def create_due_date_note - SystemNoteService.change_due_date(issuable, issuable.project, current_user, issuable.due_date) + def create_start_date_or_due_date_note(changed_dates) + return if changed_dates.blank? + + SystemNoteService.change_start_date_or_due_date(issuable, issuable.project, current_user, changed_dates) end def create_discussion_lock_note diff --git a/app/services/issuable/import_csv/base_service.rb b/app/services/issuable/import_csv/base_service.rb index 9b41c88159f..822e3cd787c 100644 --- a/app/services/issuable/import_csv/base_service.rb +++ b/app/services/issuable/import_csv/base_service.rb @@ -21,13 +21,9 @@ module Issuable def process_csv with_csv_lines.each do |row, line_no| - issuable_attributes = { - title: row[:title], - description: row[:description], - due_date: row[:due_date] - } + attributes = issuable_attributes_for(row) - if create_issuable(issuable_attributes).persisted? + if create_issuable(attributes).persisted? @results[:success] += 1 else @results[:error_lines].push(line_no) @@ -37,6 +33,14 @@ module Issuable @results[:parse_error] = true end + def issuable_attributes_for(row) + { + title: row[:title], + description: row[:description], + due_date: row[:due_date] + } + end + def with_csv_lines csv_data = @csv_io.open(&:read).force_encoding(Encoding::UTF_8) validate_headers_presence!(csv_data.lines.first) |