Merge pull request #7450 from opf/bim/set-wp-start-date-to-bcf-creation-date

On BCF-XML import set WP start date to BCF creation date
pull/7455/head
Wieland Lindenthal 5 years ago committed by GitHub
commit c251237ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      modules/bcf/app/views/bcf/issues/diff_on_work_packages.html.erb
  2. 5
      modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
  3. 2
      modules/bcf/spec/bcf/bcf_xml/importer_spec.rb
  4. 114
      modules/bcf/spec/bcf/bcf_xml/issue_reader_spec.rb
  5. 15
      modules/bcf/spec/bcf/bcf_xml/issue_writer_spec.rb
  6. 15
      modules/bcf/spec/bcf/bcf_xml/markup_extractor_spec.rb
  7. 2
      modules/bcf/spec/models/bcf/issue_spec.rb

@ -4,65 +4,6 @@
<p><%= t('bcf.bcf_xml.import.num_issues_found', x_bcf_issues: t('bcf.x_bcf_issues', count: @listing.count)) %></p>
<%= form_tag({ action: :perform_import }, multipart: true, method: :post) do %>
<%= render 'import_options_hidden_fields' %>
<%# if @importer&.invalid_people.any? %>
<!-- <h3>Invalid e-mail addresses</h3>-->
<!-- <table class="attributes-table">-->
<!-- <thead>-->
<!-- <tr>-->
<!-- <th>e-Mail address</th>-->
<!-- <th>Action</th>-->
<!-- </tr>-->
<!-- </thead>-->
<!-- <tbody>-->
<%# @importer.invalid_people.each do |mail| %>
<!-- <tr>-->
<!-- <td> <%#= mail %></td>-->
<!-- <td>Recommendation: Try to correct the data before importing here.</td>-->
<!-- </tr>-->
<%# end %>
<!-- </tbody>-->
<!-- </table>-->
<%# end %>
<hr>
<% if false #@importer.non_members.any? %>
<h3>Known, but non project members</h3>
<table class="attributes-table">
<thead>
<tr>
<th>email address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% @importer.non_members.each do |user| %>
<tr>
<td> <%= user.mail %></td>
<td>give role</td>
</tr>
<% end %>
</tbody>
</table>
<% if @roles.any? %>
<p>Do you want to add them as members to the project "<%= @project.name %>"? (Recommended)</p>
<input type="radio">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' %>
<input type="radio">No, import as <i>anonymous</i> user (not recommended)
<% else %>
<p>
<%= I18n.t('text_no_roles_defined') %>
</p>
<% end %>
<% end %>
<% @listing.each do |entry| %>

@ -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,

@ -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

@ -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
<Markup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Topic Guid="63E78882-7C6A-4BF7-8982-FC478AFB9C97" TopicType="Issue" TopicStatus="Open">
<Title>Maximum Content</Title>
<Priority>High</Priority>
<Index>0</Index>
<Labels>Structural</Labels>
<Labels>IT Development</Labels>
<CreationDate>2015-06-21T12:00:00Z</CreationDate>
<CreationAuthor>mike@example.com</CreationAuthor>
<ModifiedDate>2015-06-21T14:22:47Z</ModifiedDate>
<ModifiedAuthor>mike@example.com</ModifiedAuthor>
<AssignedTo>andy@example.com</AssignedTo>
<Description>This is a topic with all informations present.</Description>
<RelatedTopic Guid="5019D939-62A4-45D9-B205-FAB602C98FE8" />
</Topic>
<Comment Guid="780FAE52-C432-42BE-ADEA-FF3E7A8CD8E1">
<Date>2015-08-31T12:40:17Z</Date>
<Author>mike@example.com</Author>
<Comment>This is an unmodified topic at the uppermost hierarchical level.
All times in the XML are marked as UTC times.</Comment>
</Comment>
</Markup>
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

@ -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'

@ -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'

@ -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.

Loading…
Cancel
Save