diff --git a/app/models/setting.rb b/app/models/setting.rb index ab6b64a12d..2b86914328 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -150,8 +150,22 @@ class Setting < ApplicationRecord validates :value, numericality: { only_integer: true, - if: Proc.new { |setting| setting.format == :integer } + if: ->(setting) { setting.non_null_integer_format? } } + validates :value, + numericality: { + only_integer: true, + allow_nil: true, + if: ->(setting) { setting.nullable_integer_format? } + } + + def nullable_integer_format? + format == :integer && definition.default.nil? + end + + def non_null_integer_format? + format == :integer && !definition.default.nil? + end def value self.class.deserialize(name, read_attribute(:value)) diff --git a/docs/enterprise-guide/enterprise-cloud-guide/backups/README.md b/docs/enterprise-guide/enterprise-cloud-guide/backups/README.md index 1240f193ce..ba1e149ad8 100644 --- a/docs/enterprise-guide/enterprise-cloud-guide/backups/README.md +++ b/docs/enterprise-guide/enterprise-cloud-guide/backups/README.md @@ -8,12 +8,22 @@ keywords: backups # Backups -## Enterprise cloud +## Data retention policy -Your Enterprise cloud data is backed up continuously and retained for 30 days. Within those 30 days we can restore your data to any point in time with a precision of 5 minutes, in case you need us to. +Your Enterprise cloud data is backed up continuously and retained for 30 days. Within those 30 days we can restore your data to any point in time with a precision of 5 minutes, in case you need us to. (currently this is valid only for cloud instances located in the openproject.com cloud environment) *Note: At the moment it is only possible to restore the complete instance into a former state. All future edits after the former state will be not available in the restored instance. In order to offer you the possibility of recreating the restored information to your productive instance, the restored version is temporarily available on a separate URL. You will have all the time you need to clone the lost information from the temporary instance to the production one. This could be done by using e.g. API calls or manual interaction.* +## Resource limitations for attachments + +Currently resource limitations in the Enterprise Cloud allow a Backup to contain attachments only in the case if the file size of all attachments of your instance are less than 1 GB of data. Please contact us at [support@openproject.com](mailto:support@openproject.com) in order to manually request a complete backup containing the SQL dump including all attachments or try to delete unused attachments in order to get below 1 GB of data usage. + +In this case you cannot check the **Include attachments** check-box like on the screen-shot below, it will be grayed out: + +![backup-enterprise-cloud](backup-enterprise-cloud.png) + + + ## Backup via GUI -**Please navigate to the [System admin guide Backup page](../../../system-admin-guide/backup/)** +For detailed usage of the Backup via GUI, please navigate to the [System admin guide Backup page](../../../system-admin-guide/backup/) diff --git a/docs/enterprise-guide/enterprise-cloud-guide/backups/backup-enterprise-cloud.png b/docs/enterprise-guide/enterprise-cloud-guide/backups/backup-enterprise-cloud.png new file mode 100644 index 0000000000..164a281d42 Binary files /dev/null and b/docs/enterprise-guide/enterprise-cloud-guide/backups/backup-enterprise-cloud.png differ diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index be95b643ae..3f777e4e44 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -179,6 +179,47 @@ describe Setting, type: :model do expect { described_class.smtp_openssl_verify_mode = 'none' } .to raise_error NoMethodError end + + context 'for a integer setting with non-nil default value', :settings_reset do + before do + Settings::Definition.add( + 'my_setting', + format: :integer, + default: 42 + ) + end + + it 'does not save it when set to nil' do + expect(described_class.my_setting).to eq(42) + described_class.my_setting = nil + expect(described_class.my_setting).not_to be_nil + expect(described_class.my_setting).to eq(42) + end + end + + context 'for a integer setting with nil default value', :settings_reset do + before do + Settings::Definition.add( + 'my_setting', + format: :integer, + default: nil + ) + end + + it 'saves it when set to nil' do + described_class.my_setting = 42 + expect(described_class.my_setting).to eq(42) + described_class.my_setting = nil + expect(described_class.my_setting).to be_nil + end + + it 'saves it as nil when set to empty string' do + described_class.my_setting = 42 + expect(described_class.my_setting).to eq(42) + described_class.my_setting = '' + expect(described_class.my_setting).to be_nil + end + end end describe '.[setting]_writable?' do