Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

forgive missing assignee if so specified

ulfertse358e5d1fc8b
diff --git a/modules/bcf/app/services/bcf/issues/transform_attributes_service.rb b/modules/bcf/app/services/bcf/issues/transform_attributes_service.rb
index f5033766cd8..76ac8cda681 100644
--- a/modules/bcf/app/services/bcf/issues/transform_attributes_service.rb
+++ b/modules/bcf/app/services/bcf/issues/transform_attributes_service.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
diff --git a/modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb b/modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
index ce553257028..d7cf56f71b6 100644
--- a/modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
+++ b/modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
@@ -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
diff --git a/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb b/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb
index 6a7d453d3ee..0782024674a 100644
--- a/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb
+++ b/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb
@@ -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