diff --git a/modules/bcf/app/views/bcf/issues/diff_on_work_packages.html.erb b/modules/bcf/app/views/bcf/issues/diff_on_work_packages.html.erb index bc143f19bf..cd69022eff 100644 --- a/modules/bcf/app/views/bcf/issues/diff_on_work_packages.html.erb +++ b/modules/bcf/app/views/bcf/issues/diff_on_work_packages.html.erb @@ -4,65 +4,6 @@

<%= t('bcf.bcf_xml.import.num_issues_found', x_bcf_issues: t('bcf.x_bcf_issues', count: @listing.count)) %>

<%= form_tag({ action: :perform_import }, multipart: true, method: :post) do %> <%= render 'import_options_hidden_fields' %> - <%# if @importer&.invalid_people.any? %> - - - - - - - - - - <%# @importer.invalid_people.each do |mail| %> - - - - - <%# end %> - - - <%# end %> -
- - <% if false #@importer.non_members.any? %> -

Known, but non project members

- - - - - - - - - <% @importer.non_members.each do |user| %> - - - - - <% end %> - -
email addressAction
<%= user.mail %>give role
- - <% if @roles.any? %> -

Do you want to add them as members to the project "<%= @project.name %>"? (Recommended)

- - Yes, make them members with role - <% options = @roles.collect { |obj| [obj.name, obj.id] } %> - <%= select_tag 'member[role_ids][]', options_for_select(options), - multiple: false, - no_label: true, - title: l(:label_role_search), - tabIndex: 0, - class: 'form--select', - id: 'member_role_ids' %> - No, import as anonymous user (not recommended) - <% else %> -

- <%= I18n.t('text_no_roles_defined') %> -

- <% end %> - <% end %> <% @listing.each do |entry| %> 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 103f777382..83ee2dcf11 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 @@ -150,6 +150,10 @@ module OpenProject::Bcf::BcfXml end end + def start_date + extractor.creation_date unless is_update + end + def update_work_package if import_is_newer? WorkPackages::UpdateService @@ -173,6 +177,7 @@ module OpenProject::Bcf::BcfXml subject: extractor.title, description: extractor.description, due_date: extractor.due_date, + start_date: start_date, # Mapped attributes assigned_to: assignee, diff --git a/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb b/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb index ae84def052..49b0253ec1 100644 --- a/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb +++ b/modules/bcf/spec/bcf/bcf_xml/importer_spec.rb @@ -83,7 +83,7 @@ describe ::OpenProject::Bcf::BcfXml::Importer do expect(subject.import!).to be_present end - it 'creates to work packages' do + it 'creates 2 work packages' do subject.import! expect(::Bcf::Issue.count).to be_eql 2 diff --git a/modules/bcf/spec/bcf/bcf_xml/issue_reader_spec.rb b/modules/bcf/spec/bcf/bcf_xml/issue_reader_spec.rb new file mode 100644 index 0000000000..e979b2709d --- /dev/null +++ b/modules/bcf/spec/bcf/bcf_xml/issue_reader_spec.rb @@ -0,0 +1,114 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2019 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +require 'spec_helper' + +describe ::OpenProject::Bcf::BcfXml::IssueReader do + let(:absolute_file_path) { "63E78882-7C6A-4BF7-8982-FC478AFB9C97/markup.bcf" } + let(:type) { FactoryBot.create :type, name: 'Issue', is_standard: true } + let(:project) do + FactoryBot.create(:project, + identifier: 'bim_project', + types: [type]) + end + let(:manage_bcf_role) do + FactoryBot.create( + :role, + permissions: %i[manage_bcf view_linked_issues view_work_packages edit_work_packages add_work_packages] + ) + end + let(:bcf_manager) { FactoryBot.create(:user) } + let(:workflow) do + FactoryBot.create(:workflow_with_default_status, + role: manage_bcf_role, + type: type) + end + let(:priority) { FactoryBot.create :default_priority } + let(:bcf_manager_member) do + FactoryBot.create(:member, + project: project, + user: bcf_manager, + roles: [manage_bcf_role]) + end + let(:markup) do + <<-MARKUP + + + Maximum Content + High + 0 + Structural + IT Development + 2015-06-21T12:00:00Z + mike@example.com + 2015-06-21T14:22:47Z + mike@example.com + andy@example.com + This is a topic with all informations present. + + + + 2015-08-31T12:40:17Z + mike@example.com + This is an unmodified topic at the uppermost hierarchical level. + All times in the XML are marked as UTC times. + + + MARKUP + end + let(:entry) do + Struct + .new(:name, :get_input_stream) + .new(absolute_file_path, entry_stream) + end + let(:entry_stream) { StringIO.new(markup) } + + subject do + described_class.new(project, + nil, + entry, + current_user: bcf_manager, + import_options: {}, + aggregations: OpenProject::Bcf::BcfXml::Aggregations.new([], project)) + end + + before do + workflow + priority + bcf_manager_member + allow(User).to receive(:current).and_return(bcf_manager) + end + + context 'on initial import' do + let(:bcf_issue) { subject.extract! } + + it 'WP start date gets initialized with BCF CreationDate' do + expect(bcf_issue.work_package.start_date).to eql(subject.extractor.creation_date) + end + end +end diff --git a/modules/bcf/spec/bcf/bcf_xml/issue_writer_spec.rb b/modules/bcf/spec/bcf/bcf_xml/issue_writer_spec.rb index 78f93a0b5f..441387f66b 100644 --- a/modules/bcf/spec/bcf/bcf_xml/issue_writer_spec.rb +++ b/modules/bcf/spec/bcf/bcf_xml/issue_writer_spec.rb @@ -1,11 +1,18 @@ #-- copyright -# OpenProject Costs Plugin +# OpenProject is a project management system. +# Copyright (C) 2012-2019 the OpenProject Foundation (OPF) # -# Copyright (C) 2009 - 2014 the OpenProject Foundation (OPF) +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License -# version 3. +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,6 +22,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. #++ require 'spec_helper' diff --git a/modules/bcf/spec/bcf/bcf_xml/markup_extractor_spec.rb b/modules/bcf/spec/bcf/bcf_xml/markup_extractor_spec.rb index c71e838e2f..91e9c18fd9 100644 --- a/modules/bcf/spec/bcf/bcf_xml/markup_extractor_spec.rb +++ b/modules/bcf/spec/bcf/bcf_xml/markup_extractor_spec.rb @@ -1,11 +1,18 @@ #-- copyright -# OpenProject Costs Plugin +# OpenProject is a project management system. +# Copyright (C) 2012-2019 the OpenProject Foundation (OPF) # -# Copyright (C) 2009 - 2014 the OpenProject Foundation (OPF) +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License -# version 3. +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,6 +22,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. #++ require 'spec_helper' diff --git a/modules/bcf/spec/models/bcf/issue_spec.rb b/modules/bcf/spec/models/bcf/issue_spec.rb index c58b69fbc0..d7bdf2860f 100644 --- a/modules/bcf/spec/models/bcf/issue_spec.rb +++ b/modules/bcf/spec/models/bcf/issue_spec.rb @@ -1,6 +1,6 @@ #-- copyright # OpenProject is a project management system. -# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# Copyright (C) 2012-2019 the OpenProject Foundation (OPF) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 3.