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
[#53345] Synchronize only configured storages.
Pavel Balashou7e6a7fcdfde9
diff --git a/modules/storages/app/workers/storages/manage_nextcloud_integration_job_mixin.rb b/modules/storages/app/workers/storages/manage_nextcloud_integration_job_mixin.rbindex 661930c1e6b..21e096fa375 100644--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_job_mixin.rb+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_job_mixin.rb@@ -40,6 +40,8 @@ module Storagestransaction: false) do::Storages::Storage.automatic_management_enabled.includes(:oauth_client).find_each do |storage|+ next unless storage.configured?+result = service_for(storage).call(storage)result.match(on_success: ->(_) dodiff --git a/modules/storages/spec/factories/storage_factory.rb b/modules/storages/spec/factories/storage_factory.rbindex 268c8b1e96b..d6e3a048059 100644--- a/modules/storages/spec/factories/storage_factory.rb+++ b/modules/storages/spec/factories/storage_factory.rb@@ -33,12 +33,13 @@ FactoryBot.define dosequence(:name) { |n| "Storage #{n}" }creator factory: :user- # rubocop:disable FactoryBot/FactoryAssociationWithStrategy- # For some reason the order of saving breaks STItrait :with_oauth_client do- oauth_client { build(:oauth_client) }+ oauth_client+ end++ trait :with_oauth_application do+ oauth_applicationend- # rubocop:enable FactoryBot/FactoryAssociationWithStrategytrait :as_generic doprovider_type { 'Storages::Storage' }@@ -65,6 +66,11 @@ FactoryBot.define doautomatically_managed { false }end+ trait :configured do+ with_oauth_application+ with_oauth_client+ end+trait :as_healthy dohealth_status { 'healthy' }health_reason { nil }diff --git a/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb b/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rbindex 689dbb1a096..e953913e5a0 100644--- a/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb+++ b/modules/storages/spec/workers/storages/manage_nextcloud_integration_cron_job_spec.rb@@ -85,12 +85,13 @@ RSpec.describe Storages::ManageNextcloudIntegrationCronJob, :webmock, type: :jobsubject { described_class.new.perform }context 'when lock is free' do+ let(:storage1) { create(:nextcloud_storage, :as_automatically_managed, :configured) }+it 'responds with true' doexpect(subject).to be(true)endit 'calls GroupFolderPropertiesSyncService for each automatically managed storage' do- storage1 = create(:nextcloud_storage, :as_automatically_managed)storage2 = create(:nextcloud_storage, :as_not_automatically_managed)allow(Storages::NextcloudGroupFolderPropertiesSyncService)@@ -103,8 +104,6 @@ RSpec.describe Storages::ManageNextcloudIntegrationCronJob, :webmock, type: :jobendit 'marks storage as healthy if sync was successful' do- storage1 = create(:nextcloud_storage, :as_automatically_managed)-allow(Storages::NextcloudGroupFolderPropertiesSyncService).to receive(:call).with(storage1).and_return(ServiceResult.success)@@ -120,10 +119,10 @@ RSpec.describe Storages::ManageNextcloudIntegrationCronJob, :webmock, type: :jobendit 'marks storage as unhealthy if sync was unsuccessful' do- storage1 = create(:nextcloud_storage, :as_automatically_managed)-allow(Storages::NextcloudGroupFolderPropertiesSyncService)- .to receive(:call).with(storage1).and_return(ServiceResult.failure(errors: Storages::StorageError.new(code: :not_found)))+ .to receive(:call)+ .with(storage1)+ .and_return(ServiceResult.failure(errors: Storages::StorageError.new(code: :not_found)))Timecop.freeze('2023-03-14T15:17:00Z') doexpect do