mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
closes https://github.com/TryGhost/Team/issues/1491 With multiple newsletters feature, a site should always have at-least one newsletter by default. Also, as with the default product, the default newsletter also needs to be renamed to the site title during the setup flow. - adds default newsletter to main and test fixtures - updates setup flow to rename newsletter name and sender name to site title - updates model to extend default value for fields - updates test
70 lines
2.3 KiB
JavaScript
70 lines
2.3 KiB
JavaScript
const {doProductAndNewsletter} = require('../../../../../core/server/services/auth/setup');
|
|
const sinon = require('sinon');
|
|
|
|
describe('Auth Service: setup', function () {
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
describe('doProductAndNewsletter', function () {
|
|
it('updates default product and newsletter name', async function () {
|
|
const productEditStub = sinon.stub().resolves();
|
|
const newsletterEditStub = sinon.stub().resolves();
|
|
const productBrowseStub = sinon.stub().resolves({
|
|
products: [
|
|
{
|
|
id: 'product-1',
|
|
slug: 'free'
|
|
},
|
|
{
|
|
id: 'product-2',
|
|
slug: 'default-product'
|
|
}
|
|
]
|
|
});
|
|
const newsletterBrowseStub = sinon.stub().resolves({
|
|
newsletters: [
|
|
{
|
|
id: 'newsletter-1',
|
|
slug: 'fake-newsletter'
|
|
},
|
|
{
|
|
id: 'newsletter-2',
|
|
slug: 'default-newsletter'
|
|
}
|
|
]
|
|
});
|
|
let productsApi = {
|
|
browse: productBrowseStub,
|
|
edit: productEditStub
|
|
};
|
|
let newslettersApi = {
|
|
browse: newsletterBrowseStub,
|
|
edit: newsletterEditStub
|
|
};
|
|
const api = {
|
|
products: productsApi,
|
|
newsletters: newslettersApi
|
|
};
|
|
let data = {
|
|
user: {
|
|
id: 'user-1'
|
|
},
|
|
userData: {
|
|
blogTitle: 'Test Blog'
|
|
}
|
|
};
|
|
await doProductAndNewsletter(data, api);
|
|
sinon.assert.calledOnceWithExactly(
|
|
productEditStub,
|
|
{products: [{name: 'Test Blog'}]},
|
|
{context: {user: 'user-1'}, id: 'product-2'}
|
|
);
|
|
sinon.assert.calledOnceWithExactly(
|
|
newsletterEditStub,
|
|
{newsletters: [{name: 'Test Blog', sender_name: 'Test Blog'}]},
|
|
{context: {user: 'user-1'}, id: 'newsletter-2'}
|
|
);
|
|
});
|
|
});
|
|
});
|