mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added default values for Stripe config in tests
refs https://github.com/TryGhost/Toolbox/issues/214 - These variables need to be present in the configuration during the Ghost's boot time initialization, which caused a need to remember to mock settings cache before agent initialization. - By moving the values into default settings config it removes the need to do any work during test environment setup. Yey! - We should put default values in to test-specific settings-defaults.json In similar situations. Specifically, when we find a need to mock settings cache to be able to start Ghost instance in a certain state
This commit is contained in:
parent
8f17c1683d
commit
3a974f6e4e
5 changed files with 2 additions and 35 deletions
|
@ -77,7 +77,6 @@ describe('Members API without Stripe', function () {
|
|||
|
||||
describe('Members API', function () {
|
||||
before(async function () {
|
||||
mockManager.setupStripe();
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init('members');
|
||||
await agent.loginAsOwner();
|
||||
|
|
|
@ -5,12 +5,6 @@ let membersAgent;
|
|||
|
||||
describe('Members Signin', function () {
|
||||
before(async function () {
|
||||
// Weird - most of the mocks happen after getting the agent
|
||||
// but to mock stripe we want to fake the stripe keys in the settings.
|
||||
// And it's initialised at boot - so mocking it before
|
||||
// Probably wanna replace this with a settinfs fixture mock or smth??
|
||||
mockManager.setupStripe();
|
||||
|
||||
const agents = await agentProvider.getAgentsForMembers();
|
||||
membersAgent = agents.membersAgent;
|
||||
|
||||
|
|
|
@ -8,12 +8,6 @@ let adminAgent;
|
|||
|
||||
describe('Members API', function () {
|
||||
before(async function () {
|
||||
// Weird - most of the mocks happen after getting the agent
|
||||
// but to mock stripe we want to fake the stripe keys in the settings.
|
||||
// And it's initialised at boot - so mocking it before
|
||||
// Probably wanna replace this with a settinfs fixture mock or smth??
|
||||
mockManager.setupStripe();
|
||||
|
||||
const agents = await agentProvider.getAgentsForMembers();
|
||||
membersAgent = agents.membersAgent;
|
||||
adminAgent = agents.adminAgent;
|
||||
|
|
|
@ -12,7 +12,6 @@ let emailCount = 0;
|
|||
// Mockable services
|
||||
const mailService = require('../../core/server/services/mail/index');
|
||||
const labs = require('../../core/shared/labs');
|
||||
const settingsCache = require('../../core/shared/settings-cache');
|
||||
|
||||
const mockMail = () => {
|
||||
mocks.mail = sinon
|
||||
|
@ -26,24 +25,6 @@ const mockStripe = () => {
|
|||
nock.disableNetConnect();
|
||||
};
|
||||
|
||||
const setupStripe = () => {
|
||||
mocks.settings = sinon.stub(settingsCache, 'get').callsFake(function (key, ...args) {
|
||||
if (key === 'stripe_connect_secret_key') {
|
||||
return 'sk_test_blah';
|
||||
}
|
||||
if (key === 'stripe_connect_publishable_key') {
|
||||
return 'pk_test_blah';
|
||||
}
|
||||
if (key === 'stripe_connect_account_name') {
|
||||
return 'Test Account';
|
||||
}
|
||||
if (key === 'theme_session_secret') {
|
||||
return '1337_h4xx0r_53cR37';
|
||||
}
|
||||
return settingsCache.get.wrappedMethod.call(settingsCache, key, ...args);
|
||||
});
|
||||
};
|
||||
|
||||
const mockLabsEnabled = (flag, alpha = true) => {
|
||||
// We assume we should enable alpha experiments unless explicitly told not to!
|
||||
if (!alpha) {
|
||||
|
@ -114,7 +95,6 @@ const restore = () => {
|
|||
|
||||
module.exports = {
|
||||
mockMail,
|
||||
setupStripe,
|
||||
mockStripe,
|
||||
mockLabsEnabled,
|
||||
mockLabsDisabled,
|
||||
|
|
|
@ -290,11 +290,11 @@
|
|||
"type": "array"
|
||||
},
|
||||
"stripe_connect_publishable_key": {
|
||||
"defaultValue": null,
|
||||
"defaultValue": "pk_test_for_stripe",
|
||||
"type": "string"
|
||||
},
|
||||
"stripe_connect_secret_key": {
|
||||
"defaultValue": null,
|
||||
"defaultValue": "sk_test_for_stripe",
|
||||
"type": "string"
|
||||
},
|
||||
"stripe_connect_livemode": {
|
||||
|
|
Loading…
Add table
Reference in a new issue