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

adapt specs to implementation

ulferts690dc1a36e0d
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 462819cbcec..65107105c50 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -129,8 +129,8 @@ class AdminController < ApplicationController
end
def admin_information_hook_checks
- call_hook(:admin_information_checklist).map do |result|
+ call_hook(:admin_information_checklist).flat_map do |result|
result
- end.flatten(1)
+ end
end
end
diff --git a/modules/ifc_models/app/services/ifc_models/view_converter_service.rb b/modules/ifc_models/app/services/ifc_models/view_converter_service.rb
index 51ca99ba161..9a5952efdca 100644
--- a/modules/ifc_models/app/services/ifc_models/view_converter_service.rb
+++ b/modules/ifc_models/app/services/ifc_models/view_converter_service.rb
@@ -45,7 +45,7 @@ module IFCModels
end
def self.available_commands
- @available ||= begin
+ @available_commands ||= begin
PIPELINE_COMMANDS.select do |command|
_, status = Open3.capture2e('which', command)
status.exitstatus.zero?
@@ -68,21 +68,17 @@ module IFCModels
def perform_conversion!(dir)
# Step 1: IfcConvert
- Rails.logger.debug { "Converting #{ifc_model.inspect} to DAE" }
ifc_file = ifc_model.ifc_attachment.diskfile.path
collada_file = convert_to_collada(ifc_file, dir)
# Step 2: Collada2GLTF
- Rails.logger.debug { "Converting #{ifc_model.inspect} to GLTF" }
gltf_file = convert_to_gltf(collada_file, dir)
# Step 3: Convert to XKT
- Rails.logger.debug { "Converting #{ifc_model.inspect} to XKT" }
xkt_file = convert_to_xkt(gltf_file, dir)
ifc_model.xkt_attachment = File.new xkt_file
# Convert metadata
- Rails.logger.debug { "Retrieving metadata of #{ifc_model.inspect}" }
metadata_file = convert_metadata(ifc_file, dir)
ifc_model.metadata_attachment = File.new metadata_file
end
@@ -94,6 +90,8 @@ module IFCModels
# @param ifc_filepath {String} Path to the IFC model file
# @param target_dir {String} Path to the temporary output folder
def convert_to_collada(ifc_filepath, target_dir)
+ Rails.logger.debug { "Converting #{ifc_model.inspect} to DAE" }
+
convert!(ifc_filepath, target_dir, 'dae') do |target_file|
Open3.capture2e('IfcConvert', '--use-element-guids', '--no-progress', '--verbose', ifc_filepath, target_file)
end
@@ -105,6 +103,8 @@ module IFCModels
# @param dae_filepath {String} Path to the converted DAE model file
# @param target_dir {String} Path to the temporary output folder
def convert_to_gltf(dae_filepath, target_dir)
+ Rails.logger.debug { "Converting #{ifc_model.inspect} to GLTF" }
+
convert!(dae_filepath, target_dir, 'gltf') do |target_file|
Open3.capture2e('COLLADA2GLTF', '-i', dae_filepath, '-o', target_file)
end
@@ -116,6 +116,8 @@ module IFCModels
# @param gltf_filepath {String} Path to the converted GLTF model file
# @param target_dir {String} Path to the temporary output folder
def convert_to_xkt(gltf_filepath, target_dir)
+ Rails.logger.debug { "Converting #{ifc_model.inspect} to XKT" }
+
convert!(gltf_filepath, target_dir, 'xkt') do |target_file|
Open3.capture2e('gltf2xkt', '-s', gltf_filepath, '-o', target_file)
end
@@ -127,6 +129,8 @@ module IFCModels
# @param ifc_filepath {String} Path to the converted IFC model file
# @param target_dir {String} Path to the temporary output folder
def convert_metadata(ifc_filepath, target_dir)
+ Rails.logger.debug { "Retrieving metadata of #{ifc_model.inspect}" }
+
convert!(ifc_filepath, target_dir, 'json') do |target_file|
Open3.capture2e('xeokit-metadata', ifc_filepath, target_file)
end
diff --git a/modules/ifc_models/spec/models/ifc_model_spec.rb b/modules/ifc_models/spec/models/ifc_model_spec.rb
index ad6ac047e44..d24dfa033d2 100644
--- a/modules/ifc_models/spec/models/ifc_model_spec.rb
+++ b/modules/ifc_models/spec/models/ifc_model_spec.rb
@@ -17,7 +17,7 @@ describe ::IFCModels::IFCModel, type: :model do
end
describe 'ifc_attachment=' do
- subject { FactoryBot.create :ifc_model_converted }
+ subject { FactoryBot.create :ifc_model_converted, project: FactoryBot.create(:project) }
let(:ifc_attachment) { subject.ifc_attachment }
let(:new_attachment) do
FileHelpers.mock_uploaded_file name: "model.ifc", content_type: 'application/binary', binary: true
diff --git a/modules/ifc_models/spec/services/ifc_models/view_conversion_service_spec.rb b/modules/ifc_models/spec/services/ifc_models/view_conversion_service_spec.rb
index 5b260ee4f45..540c8cb40ee 100644
--- a/modules/ifc_models/spec/services/ifc_models/view_conversion_service_spec.rb
+++ b/modules/ifc_models/spec/services/ifc_models/view_conversion_service_spec.rb
@@ -4,6 +4,10 @@ describe IFCModels::ViewConverterService do
let(:model) { FactoryBot.build :ifc_model }
subject { described_class.new(model) }
+ before do
+ described_class.instance_variable_set(:@available_commands, nil)
+ end
+
shared_context 'available pipeline commands' do |available|
before do
# Mock the call to Open3 to test available commands
@@ -24,6 +28,8 @@ describe IFCModels::ViewConverterService do
end
describe '#available_commands' do
+ subject { described_class }
+
context 'with only one available command' do
include_context 'available pipeline commands', %w[IfcConvert]
@@ -46,7 +52,7 @@ describe IFCModels::ViewConverterService do
include_context 'available pipeline commands', false
it 'returns an error' do
- expect(subject).not_to be_available
+ expect(described_class).not_to be_available
result = subject.call
expect(result.errors[:base].first).to include 'The following IFC converter commands are missing'
end
@@ -54,7 +60,7 @@ describe IFCModels::ViewConverterService do
context 'if available' do
before do
- allow(subject).to receive(:available?).and_return true
+ allow(described_class).to receive(:available?).and_return true
end
it 'calls the conversion and returns save result' do