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
Handle a case when health_status is nil.
Pavel Balashou8f174ea7d6c6
diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbindex c414f173d56..0e522f56e9b 100644--- a/modules/storages/app/models/storages/storage.rb+++ b/modules/storages/app/models/storages/storage.rb@@ -89,22 +89,20 @@ module Storagesenddef mark_as_unhealthy(reason: nil)- return true if unhealthy?-update(health_status: 'unhealthy', health_changed_at: Time.now.utc, health_reason: reason)enddef mark_as_healthy- return true if healthy?-update(health_status: 'healthy', health_changed_at: Time.now.utc, health_reason: nil)enddef healthy?+ mark_as_healthy if health_status.nil?health_status == 'healthy'enddef unhealthy?+ mark_as_healthy if health_status.nil?health_status == 'unhealthy'enddiff --git a/modules/storages/spec/models/storages/nextcloud_storage_spec.rb b/modules/storages/spec/models/storages/nextcloud_storage_spec.rbindex e6f330a734d..fb9cf6a3eb7 100644--- a/modules/storages/spec/models/storages/nextcloud_storage_spec.rb+++ b/modules/storages/spec/models/storages/nextcloud_storage_spec.rb@@ -76,6 +76,40 @@ RSpec.describe Storages::NextcloudStorage doendend+ describe '#healthy?' do+ it 'marks as healthy if health_status is nil' do+ expect do+ storage.healthy?+ end.to(change(storage, :health_status).from(nil).to('healthy'))+ expect(storage).to be_healthy+ end++ it 'does not mark as healthy if health_status has been defined earlier' do+ storage.mark_as_unhealthy+ expect do+ storage.healthy?+ end.not_to(change(storage, :health_status).from('unhealthy'))+ expect(storage).not_to be_healthy+ end+ end++ describe '#unhealthy?' do+ it 'marks as healthy if health_status is nil' do+ expect do+ storage.unhealthy?+ end.to(change(storage, :health_status).from(nil).to('healthy'))+ expect(storage).to be_healthy+ end++ it 'does not mark as healthy if health_status has been defined earlier' do+ storage.mark_as_healthy+ expect do+ storage.unhealthy?+ end.not_to(change(storage, :health_status).from('healthy'))+ expect(storage).not_to be_unhealthy+ end+ end+describe '#configured?' docontext 'with a complete configuration' dolet(:storage) do