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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix the expectations on CopyProjectfoldersJob
Marcello Rocha499cd335d7b0
diff --git a/modules/storages/app/workers/storages/copy_project_folders_job.rb b/modules/storages/app/workers/storages/copy_project_folders_job.rbindex 0e0d6eec709..d6256af7f09 100644--- a/modules/storages/app/workers/storages/copy_project_folders_job.rb+++ b/modules/storages/app/workers/storages/copy_project_folders_job.rb@@ -30,11 +30,12 @@module Storagesclass CopyProjectFoldersJob < ApplicationJob+ include TaggedLogginginclude GoodJob::ActiveJobExtensions::Batches- retry_on Errors::PollingRequired, attempts: 50, wait: ->(executions) do+ retry_on Errors::PollingRequired, attempts: 50, wait: lambda { |executions|(executions**2) + (Kernel.rand * (executions**2) * 0.15) + 2- end+ }discard_on HTTPX::HTTPErrordef perform(source:, target:, work_packages_map:)@@ -92,14 +93,16 @@ module Storagesreturnin { failure: true, errors: StorageError }failed.errors.to_active_model_errors.full_messages+ in { failure: true, errors: ActiveModel::Errors }+ failed.errors.full_messageselse- failed.errors.to_s+ failed.errorsendbatch.properties[:errors].push(*batch_errors)batch.save- OpenProject.logger.warn failed.errors.to_s+ error batch_errorsenddef polling_infodiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 6f3db0eeef6..49fb6d73d73 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -88,11 +88,11 @@ en:errors:models:copy_project_folders_service:- conflict: "The folder %{destination_path} already exists. Interrupting process to avoid overwrites."- not_found: "The source template location %{source_path} wasn't found."- unauthorized: "OpenProject could not authenticate with the Storage Provider. Please check your storage configuration"- forbidden: "OpenProject could not access the source folder. Please check your permissions configuration on the Storage Provider"- error: "An unexpected error occurred. Please check OpenProject logs for more information or contact an administrator"+ conflict: The folder %{destination_path} already exists. Interrupting process to avoid overwrites.+ error: An unexpected error occurred. Please check OpenProject logs for more information or contact an administrator+ forbidden: OpenProject could not access the source folder. Please check your permissions configuration on the Storage Provider+ not_found: The source template location %{source_path} wasn't found.+ unauthorized: OpenProject could not authenticate with the Storage Provider. Please check your storage configurationnextcloud_sync_service:attributes:add_user_to_group:diff --git a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rbindex 09a4588b6ea..e18d777736b 100644--- a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb+++ b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb@@ -123,18 +123,18 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_badescribe "managed project folders" dobefore doStorages::Peripherals::Registry- .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", ->(storage:, auth_strategy:, folder:) {+ .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:|ServiceResult.success(result: target_deep_file_ids)})Storages::Peripherals::Registry- .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, auth_strategy:, file_ids:) {+ .stub("#{storage.short_provider_type}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:|ServiceResult.success(result: source_file_infos)})Storages::Peripherals::Registry.stub("#{storage.short_provider_type}.commands.copy_template_folder",- ->(auth_strategy:, storage:, source_path:, destination_path:) {+ lambda { |auth_strategy:, storage:, source_path:, destination_path:|ServiceResult.success(result: copy_result.with(id: "copied-folder", polling_url:))})end@@ -173,17 +173,17 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_babefore doStorages::Peripherals::Registry.stub("#{storage.short_provider_type}.commands.copy_template_folder",- ->(auth_strategy:, storage:, source_path:, destination_path:) {+ lambda { |auth_strategy:, storage:, source_path:, destination_path:|ServiceResult.success(result: copy_result.with(polling_url:, requires_polling: true))})Storages::Peripherals::Registry- .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", ->(storage:, auth_strategy:, folder:) {+ .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:|ServiceResult.success(result: target_deep_file_ids)})Storages::Peripherals::Registry- .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, auth_strategy:, file_ids:) {+ .stub("#{storage.short_provider_type}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:|ServiceResult.success(result: source_file_infos)})@@ -239,7 +239,7 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_babefore doStorages::Peripherals::Registry.stub("#{storage.short_provider_type}.commands.copy_template_folder",- ->(auth_strategy:, storage:, source_path:, destination_path:) {+ lambda { |auth_strategy:, storage:, source_path:, destination_path:|ServiceResult.failure(result: :error,errors: Storages::StorageError.new(code: :error, log_message: "General Failure reporting for duty")@@ -259,13 +259,12 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_baendit "logs the error" do- allow(OpenProject.logger).to receive(:warn)+ allow(Rails.logger).to receive(:error)GoodJob::Batch.enqueue(user:, errors: []) { described_class.perform_later(source:, target:, work_packages_map:) }GoodJob.perform_inline- expect(OpenProject.logger).to have_received(:warn)- .with("error | General Failure reporting for duty")- .once+ expect(Rails.logger)+ .to have_received(:error).with([I18n.t("services.errors.models.copy_project_folders_service.error")]).onceendend# rubocop:enable Lint/UnusedBlockArgument