debian-mirror-gitlab/app/services/issuable/import_csv/base_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
708 B
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Issuable
module ImportCsv
2023-04-23 21:23:45 +05:30
class BaseService < ::ImportCsv::BaseService
extend ::Gitlab::Utils::Override
2021-01-29 00:20:46 +05:30
private
2023-04-23 21:23:45 +05:30
override :attributes_for
def attributes_for(row)
2022-08-27 11:52:29 +05:30
{
title: row[:title],
description: row[:description],
due_date: row[:due_date]
}
end
2023-04-23 21:23:45 +05:30
override :validate_headers_presence!
2021-02-22 17:27:13 +05:30
def validate_headers_presence!(headers)
headers.downcase! if headers
return if headers && headers.include?('title') && headers.include?('description')
2021-01-29 00:20:46 +05:30
2023-05-27 22:25:52 +05:30
raise CSV::MalformedCSVError.new('Invalid CSV format - missing required headers.', 1)
2021-01-29 00:20:46 +05:30
end
end
end
end