Merge remote-tracking branch 'origin/release/11.4' into dev

pull/9709/head
Oliver Günther 3 years ago
commit a2b8d2001d
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 1
      config/locales/en.yml
  2. 3
      config/settings.yml
  3. 5
      modules/bim/app/models/bim/ifc_models/ifc_model.rb
  4. 1
      modules/bim/app/services/bim/ifc_models/set_attributes_service.rb
  5. 10
      modules/bim/app/workers/bim/ifc_models/ifc_conversion_job.rb
  6. 28
      modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb
  7. 26
      modules/bim/spec/features/ifc_models/ifc_upload_shared_examples.rb
  8. 36
      modules/bim/spec/features/ifc_models/regular_ifc_upload_spec.rb

@ -2534,6 +2534,7 @@ en:
Set the number of days notification events for users (the source for in-app notifications)
will be kept in the system. Any events older than this time will be deleted.
events_explanation: 'Governs for which event an email is sent out. Work packages are excluded from this list as the notifications for them can be configured specifically for every user.'
delay_minutes_explanation: "Email sending can be delayed to allow users with configured in app notification to confirm the notification within the application before a mail is sent out. Users who read a notification within the application will not receive an email for the already read notification."
display:
first_date_of_week_and_year_set: >
If either options "%{day_of_week_setting_name}" or "%{first_week_setting_name}" are set,

@ -382,3 +382,6 @@ apiv3_docs_enabled:
notification_retention_period_days:
default: 30
format: int
attachment_whitelist:
serialized: true
default: []

@ -13,7 +13,7 @@ module Bim
scope :defaults, -> { where(is_default: true) }
%i(ifc xkt metadata).each do |name|
%i(ifc xkt).each do |name|
define_method "#{name}_attachment" do
get_attached_type(name)
end
@ -25,9 +25,10 @@ module Bim
end
delete_attachment name
filename = file.respond_to?(:original_filename) ? file.original_filename : File.basename(file.path)
call = ::Attachments::CreateService
.bypass_whitelist(user: User.current)
.call(file: file, container: self, filename: Pathname(file.path).basename, description: name)
.call(file: file, container: self, filename: filename, description: name)
call.on_failure { Rails.logger.error "Failed to add #{name} attachment: #{call.message}" }
end

@ -34,6 +34,7 @@ module Bim
protected
def set_attributes(params)
model.project = params[:project] if params.key?(:project)
set_ifc_attachment(params.delete(:ifc_attachment))
super

@ -6,11 +6,13 @@ module Bim
##
# Run the conversion of IFC to
def perform(ifc_model)
result = ViewConverterService.new(ifc_model).call
User.system.run_given do
result = ViewConverterService.new(ifc_model).call
unless result.success?
errors = result.errors.full_messages.join(". ")
Rails.logger.error "Failed to convert IFC model #{ifc_model.inspect}: #{errors}"
unless result.success?
errors = result.errors.full_messages.join(". ")
Rails.logger.error "Failed to convert IFC model #{ifc_model.inspect}: #{errors}"
end
end
end
end

@ -27,31 +27,11 @@
#++
require 'spec_helper'
require_relative './ifc_upload_shared_examples'
describe 'direct IFC upload', type: :feature, js: true, with_direct_uploads: :redirect, with_config: { edition: 'bim' } do
let(:user) { FactoryBot.create :admin }
let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim] }
let(:ifc_fixture) { ::UploadedFile.load_from('modules/bim/spec/fixtures/files/minimal.ifc') }
before do
login_as user
allow_any_instance_of(Bim::IfcModels::BaseContract).to receive(:ifc_attachment_is_ifc).and_return true
end
it 'should work' do
visit new_bcf_project_ifc_model_path(project_id: project.identifier)
page.attach_file("file", ifc_fixture.path, visible: :all)
click_on "Create"
expect(page).to have_content("Upload succeeded")
expect(Attachment.count).to eq 1
expect(Attachment.first[:file]).to eq 'model.ifc'
expect(Bim::IfcModels::IfcModel.count).to eq 1
expect(Bim::IfcModels::IfcModel.first.title).to eq "minimal.ifc"
it_behaves_like 'can upload an IFC file' do
# with direct upload, we don't get the model name
let(:model_name) { 'model.ifc' }
end
end

@ -0,0 +1,26 @@
shared_examples 'can upload an IFC file' do
let(:user) { FactoryBot.create :admin }
let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim] }
let(:ifc_fixture) { ::UploadedFile.load_from('modules/bim/spec/fixtures/files/minimal.ifc') }
before do
login_as user
allow_any_instance_of(Bim::IfcModels::BaseContract).to receive(:ifc_attachment_is_ifc).and_return true
end
it 'should allow uploading an IFC file' do
visit new_bcf_project_ifc_model_path(project_id: project.identifier)
page.attach_file("file", ifc_fixture.path, visible: :all)
click_on "Create"
expect(page).to have_content("Upload succeeded")
expect(Attachment.count).to eq 1
expect(Attachment.first[:file]).to eq model_name
expect(Bim::IfcModels::IfcModel.count).to eq 1
end
end

@ -0,0 +1,36 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# 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-2013 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'
require_relative './ifc_upload_shared_examples'
describe 'IFC upload', type: :feature, js: true, with_config: { edition: 'bim' } do
it_behaves_like 'can upload an IFC file' do
let(:model_name) { 'minimal.ifc' }
end
end
Loading…
Cancel
Save