forgive missing assignee if so specified

pull/7893/head
ulferts 5 years ago
parent a344d35e90
commit e358e5d1fc
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 26
      modules/bcf/app/services/bcf/issues/transform_attributes_service.rb
  2. 4
      modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
  3. 2
      modules/bcf/spec/bcf/bcf_xml/importer_spec.rb

@ -56,9 +56,7 @@ module Bcf::Issues
return assignee if assignee.present?
if attributes[:assignee]
User::InexistentUser.new
end
missing_assignee(attributes[:assignee], attributes[:import_options] || {})
end
##
@ -67,13 +65,13 @@ module Bcf::Issues
project.users.find_by(mail: mail)
end
def type(attributes)
def type(project, attributes)
type_name = attributes[:type]
type = ::Type.find_by(name: type_name)
type = project.types.find_by(name: type_name)
return type if type.present?
missing_type(type_name, attributes[:import_options] || {})
missing_type(project, type_name, attributes[:import_options] || {})
end
##
@ -107,7 +105,7 @@ module Bcf::Issues
{
# Fixed attributes we know
project: project,
type: type(attributes),
type: type(project, attributes),
# Native attributes from the extractor
subject: title(attributes),
@ -144,15 +142,21 @@ module Bcf::Issues
end
end
def missing_type(type_name, import_options)
if import_options[:unknown_types_action] == 'default'
::Type.default&.first
def missing_type(project, type_name, import_options)
if import_options[:unknown_types_action] == 'use_default'
project.types.default&.first
elsif import_options[:unknown_types_action] == 'chose' &&
import_options[:unknown_types_chose_ids].any?
::Type.find_by(id: import_options[:unknown_types_chose_ids].first)
project.types.find_by(id: import_options[:unknown_types_chose_ids].first)
elsif type_name
Type::InexistentType.new
end
end
def missing_assignee(assignee_name, import_options)
if import_options[:invalid_people_action] != 'anonymize' && assignee_name
User::InexistentUser.new
end
end
end
end

@ -93,9 +93,9 @@ module OpenProject::Bcf::BcfXml
def work_package_attributes
attributes = ::Bcf::Issues::TransformAttributesService
.new
.call(extractor_attributes)
.call(extractor_attributes.merge(import_options: import_options))
.result
.merge(send_notifications: false, import_options: import_options)
.merge(send_notifications: false)
.symbolize_keys
attributes[:start_date] = extractor.creation_date.to_date unless is_update

@ -63,7 +63,7 @@ describe ::OpenProject::Bcf::BcfXml::Importer do
workflow
priority
bcf_manager_member
allow(User).to receive(:current).and_return(bcf_manager)
login_as(bcf_manager)
end
describe '#to_listing' do

Loading…
Cancel
Save