diff --git a/ghost/core/core/server/data/migrations/versions/5.58/2023-08-02-09-42-add-donation-settings.js b/ghost/core/core/server/data/migrations/versions/5.58/2023-08-02-09-42-add-donation-settings.js new file mode 100644 index 0000000000..acfc8ae08c --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/5.58/2023-08-02-09-42-add-donation-settings.js @@ -0,0 +1,16 @@ +const {combineTransactionalMigrations, addSetting} = require('../../utils'); + +module.exports = combineTransactionalMigrations( + addSetting({ + key: 'donations_currency', + value: 'USD', + type: 'string', + group: 'donations' + }), + addSetting({ + key: 'donations_suggested_amount', + value: 0, + type: 'number', + group: 'donations' + }) +); diff --git a/ghost/core/core/server/data/schema/default-settings/default-settings.json b/ghost/core/core/server/data/schema/default-settings/default-settings.json index 18b2ee5cc7..5a79fde169 100644 --- a/ghost/core/core/server/data/schema/default-settings/default-settings.json +++ b/ghost/core/core/server/data/schema/default-settings/default-settings.json @@ -549,5 +549,21 @@ "defaultValue": null, "type": "string" } + }, + "donations": { + "donations_currency": { + "defaultValue": "USD", + "validations": { + "isEmpty": false + }, + "type": "string" + }, + "donations_suggested_amount": { + "defaultValue": 0, + "validations": { + "isEmpty": false + }, + "type": "number" + } } } diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap index b29916086c..baf27521f3 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap @@ -304,6 +304,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -694,6 +702,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -718,7 +734,7 @@ exports[`Settings API Edit Can edit a setting 2: [headers] 1`] = ` Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "4012", + "content-length": "4104", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, @@ -1032,6 +1048,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -1369,6 +1393,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -1711,6 +1743,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -2141,6 +2181,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, @@ -2543,6 +2591,14 @@ Object { "key": "pintura_css_url", "value": null, }, + Object { + "key": "donations_currency", + "value": "USD", + }, + Object { + "key": "donations_suggested_amount", + "value": "0", + }, Object { "key": "members_enabled", "value": true, diff --git a/ghost/core/test/e2e-api/admin/settings.test.js b/ghost/core/test/e2e-api/admin/settings.test.js index 030d4d939d..40a5cd703d 100644 --- a/ghost/core/test/e2e-api/admin/settings.test.js +++ b/ghost/core/test/e2e-api/admin/settings.test.js @@ -8,7 +8,7 @@ const {stringMatching, anyEtag, anyUuid, anyContentLength, anyContentVersion} = const models = require('../../../core/server/models'); const {anyErrorId} = matchers; -const CURRENT_SETTINGS_COUNT = 79; +const CURRENT_SETTINGS_COUNT = 81; const settingsMatcher = {}; diff --git a/ghost/core/test/regression/models/model_settings.test.js b/ghost/core/test/regression/models/model_settings.test.js index 285891ddb1..a3f930466b 100644 --- a/ghost/core/test/regression/models/model_settings.test.js +++ b/ghost/core/test/regression/models/model_settings.test.js @@ -5,7 +5,7 @@ const db = require('../../../core/server/data/db'); // Stuff we are testing const models = require('../../../core/server/models'); -const SETTINGS_LENGTH = 90; +const SETTINGS_LENGTH = 92; describe('Settings Model', function () { before(models.init); diff --git a/ghost/core/test/unit/server/data/exporter/index.test.js b/ghost/core/test/unit/server/data/exporter/index.test.js index 5dd93ca653..cb3c2e3995 100644 --- a/ghost/core/test/unit/server/data/exporter/index.test.js +++ b/ghost/core/test/unit/server/data/exporter/index.test.js @@ -236,7 +236,7 @@ describe('Exporter', function () { // NOTE: if default settings changed either modify the settings keys blocklist or increase allowedKeysLength // This is a reminder to think about the importer/exporter scenarios ;) - const allowedKeysLength = 82; + const allowedKeysLength = 84; totalKeysLength.should.eql(SETTING_KEYS_BLOCKLIST.length + allowedKeysLength); }); }); diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index f043ed8cfb..86fcb9a1ec 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -37,7 +37,7 @@ describe('DB version integrity', function () { // Only these variables should need updating const currentSchemaHash = '99a8fe2394b685cc1ce4c44d8e87a1ad'; const currentFixturesHash = 'af43eef1ac4f14fc1bc0ea351300420f'; - const currentSettingsHash = '4f23a583335dcb4cb3fae553122ea200'; + const currentSettingsHash = 'dd0e318627ded65e41f188fb5bdf5b74'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01'; // If this test is failing, then it is likely a change has been made that requires a DB version bump, diff --git a/ghost/core/test/utils/fixtures/default-settings.json b/ghost/core/test/utils/fixtures/default-settings.json index b920c22b7d..ff2e899ce8 100644 --- a/ghost/core/test/utils/fixtures/default-settings.json +++ b/ghost/core/test/utils/fixtures/default-settings.json @@ -557,5 +557,21 @@ "defaultValue": null, "type": "string" } + }, + "donations": { + "donations_currency": { + "defaultValue": "USD", + "validations": { + "isEmpty": false + }, + "type": "string" + }, + "donations_suggested_amount": { + "defaultValue": 0, + "validations": { + "isEmpty": false + }, + "type": "number" + } } }