mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 05:42:32 +03:00
Handled default newsletter fixtures setup (#14459)
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
This commit is contained in:
parent
89ea9de5a5
commit
95670eed52
@ -51,14 +51,14 @@ module.exports = {
|
||||
})
|
||||
.then((data) => {
|
||||
try {
|
||||
return auth.setup.doFixtures(data, api.products);
|
||||
return auth.setup.doFixtures(data);
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
try {
|
||||
return auth.setup.doProduct(data, api.products);
|
||||
return auth.setup.doProductAndNewsletter(data, api);
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
|
@ -133,6 +133,9 @@ function serializeMember(member, options) {
|
||||
}
|
||||
|
||||
if (json.newsletters && labsService.isSet('multipleNewsletters')) {
|
||||
json.newsletters.sort((a, b) => {
|
||||
return a.sort_order - b.sort_order;
|
||||
});
|
||||
serialized.newsletters = json.newsletters;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,16 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Newsletter",
|
||||
"entries": [
|
||||
{
|
||||
"name": "Default Newsletter",
|
||||
"slug": "default-newsletter",
|
||||
"sender_name": "Ghost"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tag",
|
||||
"entries": [
|
||||
|
@ -13,7 +13,9 @@ const Newsletter = ghostBookshelf.Model.extend({
|
||||
title_alignment: 'center',
|
||||
show_feature_image: true,
|
||||
body_font_category: 'sans_serif',
|
||||
show_badge: true
|
||||
show_badge: true,
|
||||
show_header_icon: true,
|
||||
show_header_title: true
|
||||
},
|
||||
|
||||
async onSaving(model, _attr, options) {
|
||||
|
@ -107,7 +107,9 @@ async function doSettings(data, settingsAPI) {
|
||||
return user;
|
||||
}
|
||||
|
||||
async function doProduct(data, productsAPI) {
|
||||
// Update names for default product and newsletter to site title
|
||||
async function doProductAndNewsletter(data, api) {
|
||||
const {products: productsAPI, newsletters: newslettersAPI} = api;
|
||||
const context = {context: {user: data.user.id}};
|
||||
const user = data.user;
|
||||
const blogTitle = data.userData.blogTitle;
|
||||
@ -116,15 +118,24 @@ async function doProduct(data, productsAPI) {
|
||||
return user;
|
||||
}
|
||||
try {
|
||||
const page = await productsAPI.browse({limit: 'all'});
|
||||
const productPage = await productsAPI.browse({limit: 'all'});
|
||||
const newsletterPage = await newslettersAPI.browse({limit: 'all'});
|
||||
|
||||
const product = page.products.find(p => p.slug === 'default-product');
|
||||
const defaultProduct = productPage.products.find(p => p.slug === 'default-product');
|
||||
const defaultNewsletter = newsletterPage.newsletters.find(p => p.slug === 'default-newsletter');
|
||||
|
||||
if (!product) {
|
||||
return data;
|
||||
if (defaultProduct) {
|
||||
await productsAPI.edit({products: [{
|
||||
name: blogTitle.trim()
|
||||
}]}, {context: context.context, id: defaultProduct.id});
|
||||
}
|
||||
|
||||
await productsAPI.edit({products: [{name: blogTitle.trim()}]}, {context: context.context, id: product.id});
|
||||
if (defaultNewsletter) {
|
||||
await newslettersAPI.edit({newsletters: [{
|
||||
name: blogTitle.trim(),
|
||||
sender_name: blogTitle.trim()
|
||||
}]}, {context: context.context, id: defaultNewsletter.id});
|
||||
}
|
||||
} catch (e) {
|
||||
return data;
|
||||
}
|
||||
@ -221,7 +232,7 @@ module.exports = {
|
||||
assertSetupCompleted: assertSetupCompleted,
|
||||
setupUser: setupUser,
|
||||
doSettings: doSettings,
|
||||
doProduct: doProduct,
|
||||
doProductAndNewsletter: doProductAndNewsletter,
|
||||
installTheme: installTheme,
|
||||
doFixtures: doFixtures,
|
||||
sendWelcomeEmail: sendWelcomeEmail
|
||||
|
@ -2004,14 +2004,14 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: wit multiple newsletters Can browse 1: [body] 1`] = `
|
||||
exports[`Members API: with multiple newsletters Can add and edit with custom newsletters 1: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "member1@test.com",
|
||||
"email": "memberTestAddNewsletter2@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
@ -2019,196 +2019,64 @@ Object {
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Mr Egg",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"name": "test newsletter",
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Weekly newsletter",
|
||||
"sender_email": "jamie@example.com",
|
||||
"sender_name": "Jamie",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "weekly-newsletter",
|
||||
"sort_order": 2,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
"note": "test note",
|
||||
"products": Array [],
|
||||
"status": "free",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "member2@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": 50,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": null,
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "free",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "paid@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": 80,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Egon Spengler",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "paid",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "trialing@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Ray Stantz",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "paid",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "comped@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Vinz Clortho",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "paid",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "vip@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Winston Zeddemore",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "free",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "vip-paid@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Peter Venkman",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "paid",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "with-product@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Dana Barrett",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "paid",
|
||||
"subscribed": true,
|
||||
"subscribed": false,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
],
|
||||
"meta": Object {
|
||||
"pagination": Object {
|
||||
"limit": 15,
|
||||
"next": null,
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"prev": null,
|
||||
"total": 8,
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: wit multiple newsletters Can browse 2: [headers] 1`] = `
|
||||
exports[`Members API: with multiple newsletters Can add and edit with custom newsletters 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": "8435",
|
||||
"content-length": "1145",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/members\\\\/\\[a-f0-9\\]\\{24\\}\\\\//,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: wit multiple newsletters Can read 1: [body] 1`] = `
|
||||
exports[`Members API: with multiple newsletters Can add and edit with custom newsletters 3: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "member1@test.com",
|
||||
"email": "memberTestAddNewsletter2@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
@ -2216,12 +2084,35 @@ Object {
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Mr Egg",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"name": "test newsletter",
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Daily newsletter",
|
||||
"sender_email": "jamie@example.com",
|
||||
"sender_name": "Jamie",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "daily-newsletter",
|
||||
"sort_order": 1,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
"note": "test note",
|
||||
"products": Array [],
|
||||
"status": "free",
|
||||
"subscribed": true,
|
||||
"subscribed": false,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
@ -2230,11 +2121,11 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: wit multiple newsletters Can read 2: [headers] 1`] = `
|
||||
exports[`Members API: with multiple newsletters Can add and edit with custom newsletters 4: [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": "607",
|
||||
"content-length": "1143",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
@ -2259,6 +2150,28 @@ Object {
|
||||
"last_seen_at": null,
|
||||
"name": "test",
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "sans_serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Default Newsletter",
|
||||
"sender_email": null,
|
||||
"sender_name": "Ghost",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "default-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "sans_serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
@ -2274,7 +2187,7 @@ Object {
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "daily-newsletter",
|
||||
"sort_order": 0,
|
||||
"sort_order": 1,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
@ -2296,7 +2209,7 @@ Object {
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "weekly-newsletter",
|
||||
"sort_order": 0,
|
||||
"sort_order": 2,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
@ -2320,7 +2233,7 @@ exports[`Members API: with multiple newsletters Can add with default newsletters
|
||||
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": "1630",
|
||||
"content-length": "2126",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/members\\\\/\\[a-f0-9\\]\\{24\\}\\\\//,
|
||||
@ -2329,135 +2242,6 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: with multiple newsletters Can and and edit with custom newsletters 1: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "memberTestAddNewsletter2@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "test newsletter",
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Weekly newsletter",
|
||||
"sender_email": "jamie@example.com",
|
||||
"sender_name": "Jamie",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "weekly-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
"note": "test note",
|
||||
"products": Array [],
|
||||
"status": "free",
|
||||
"subscribed": false,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: with multiple newsletters Can and and edit with custom newsletters 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": "1145",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/members\\\\/\\[a-f0-9\\]\\{24\\}\\\\//,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: with multiple newsletters Can and and edit with custom newsletters 3: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "memberTestAddNewsletter2@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "test newsletter",
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Daily newsletter",
|
||||
"sender_email": "jamie@example.com",
|
||||
"sender_name": "Jamie",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "daily-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
"note": "test note",
|
||||
"products": Array [],
|
||||
"status": "free",
|
||||
"subscribed": false,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: with multiple newsletters Can and and edit with custom newsletters 4: [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": "1143",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API: with multiple newsletters Can browse 1: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
|
@ -51,10 +51,32 @@ Object {
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"prev": null,
|
||||
"total": 1,
|
||||
"total": 2,
|
||||
},
|
||||
},
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "sans_serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Default Newsletter",
|
||||
"sender_email": null,
|
||||
"sender_name": "Ghost",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "default-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "sans_serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
@ -85,7 +107,7 @@ exports[`Newsletters API Can add a newsletter 4: [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": "604",
|
||||
"content-length": "1100",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
@ -102,10 +124,32 @@ Object {
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"prev": null,
|
||||
"total": 1,
|
||||
"total": 2,
|
||||
},
|
||||
},
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "sans_serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Default Newsletter",
|
||||
"sender_email": null,
|
||||
"sender_name": "Ghost",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "default-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "sans_serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"description": null,
|
||||
@ -136,7 +180,7 @@ exports[`Newsletters API Can browse newsletters 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": "604",
|
||||
"content-length": "1100",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
@ -149,34 +193,34 @@ Object {
|
||||
"meta": Object {
|
||||
"pagination": Object {
|
||||
"limit": 1,
|
||||
"next": null,
|
||||
"next": 2,
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"pages": 2,
|
||||
"prev": null,
|
||||
"total": 1,
|
||||
"total": 2,
|
||||
},
|
||||
},
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"body_font_category": "sans_serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "My test newsletter",
|
||||
"sender_email": "test@example.com",
|
||||
"sender_name": "Test",
|
||||
"name": "Default Newsletter",
|
||||
"sender_email": null,
|
||||
"sender_name": "Ghost",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "my-test-newsletter",
|
||||
"slug": "default-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"title_font_category": "sans_serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
@ -187,7 +231,7 @@ exports[`Newsletters API Can edit newsletters 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": "603",
|
||||
"content-length": "597",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
@ -199,25 +243,25 @@ exports[`Newsletters API Can edit newsletters 3: [body] 1`] = `
|
||||
Object {
|
||||
"newsletters": Array [
|
||||
Object {
|
||||
"body_font_category": "serif",
|
||||
"body_font_category": "sans_serif",
|
||||
"description": null,
|
||||
"footer_content": null,
|
||||
"header_image": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Updated newsletter name",
|
||||
"sender_email": "test@example.com",
|
||||
"sender_name": "Test",
|
||||
"sender_email": null,
|
||||
"sender_name": "Ghost",
|
||||
"sender_reply_to": "newsletter",
|
||||
"show_badge": true,
|
||||
"show_feature_image": true,
|
||||
"show_header_icon": true,
|
||||
"show_header_title": true,
|
||||
"slug": "my-test-newsletter",
|
||||
"slug": "default-newsletter",
|
||||
"sort_order": 0,
|
||||
"status": "active",
|
||||
"subscribe_on_signup": true,
|
||||
"title_alignment": "center",
|
||||
"title_font_category": "serif",
|
||||
"title_font_category": "sans_serif",
|
||||
"visibility": "members",
|
||||
},
|
||||
],
|
||||
@ -228,7 +272,7 @@ exports[`Newsletters API Can edit newsletters 4: [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": "521",
|
||||
"content-length": "518",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
|
@ -1374,7 +1374,7 @@ describe('Members API: with multiple newsletters', function () {
|
||||
updated_at: anyISODateTime,
|
||||
subscriptions: anyArray,
|
||||
labels: anyArray,
|
||||
newsletters: Array(2).fill({
|
||||
newsletters: Array(3).fill({
|
||||
id: matchers.anyObjectId
|
||||
})
|
||||
}]
|
||||
@ -1386,7 +1386,7 @@ describe('Members API: with multiple newsletters', function () {
|
||||
});
|
||||
|
||||
// Edit a member
|
||||
it('Can and and edit with custom newsletters', async function () {
|
||||
it('Can add and edit with custom newsletters', async function () {
|
||||
// Add custom newsletter list to new member
|
||||
const member = {
|
||||
name: 'test newsletter',
|
||||
|
@ -42,7 +42,7 @@ describe('Newsletters API', function () {
|
||||
.body({newsletters: [newsletter]})
|
||||
.expectStatus(201)
|
||||
.matchBodySnapshot({
|
||||
newsletters: [newsletterSnapshot]
|
||||
newsletters: new Array(1).fill(newsletterSnapshot)
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag,
|
||||
@ -52,7 +52,7 @@ describe('Newsletters API', function () {
|
||||
await agent.get('newsletters/')
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot({
|
||||
newsletters: [newsletterSnapshot]
|
||||
newsletters: new Array(2).fill(newsletterSnapshot)
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
@ -63,7 +63,7 @@ describe('Newsletters API', function () {
|
||||
await agent.get('newsletters/')
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot({
|
||||
newsletters: [newsletterSnapshot]
|
||||
newsletters: new Array(2).fill(newsletterSnapshot)
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
|
@ -93,10 +93,19 @@ describe('Authentication API', function () {
|
||||
|
||||
// Test that the default Tier has been renamed from 'Default Product'
|
||||
const {body} = await agent.get('/tiers/');
|
||||
|
||||
const tierWithDefaultProductName = body.tiers.find(x => x.name === 'Default Product');
|
||||
|
||||
assert(tierWithDefaultProductName === undefined, 'The default Tier should have had a name change');
|
||||
|
||||
// Test that the default Newsletter has name and sender name changed to blog title
|
||||
const {body: newsletterBody} = await agent.get('/newsletters/');
|
||||
const defaultNewsletter = newsletterBody.newsletters.find(x => x.slug === 'default-newsletter');
|
||||
const newsletterWithDefaultName = newsletterBody.newsletters.find(x => x.name
|
||||
=== 'Default Newsletter');
|
||||
|
||||
assert (defaultNewsletter.name === 'a test blog', 'The default newsletter should have had a name change');
|
||||
assert (defaultNewsletter.sender_name === 'a test blog', 'The default newsletter should have had a sender name change');
|
||||
assert(newsletterWithDefaultName === undefined, 'The default newsletter should have had a name change');
|
||||
});
|
||||
|
||||
it('is setup? yes', async function () {
|
||||
|
@ -119,6 +119,27 @@ describe('Migration Fixture Utils', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('should call add for main newsletter fixture', function (done) {
|
||||
const newsletterOneStub = sinon.stub(models.Newsletter, 'findOne').returns(Promise.resolve());
|
||||
const newsletterAddStub = sinon.stub(models.Newsletter, 'add').returns(Promise.resolve({}));
|
||||
|
||||
const newsletterFixtures = fixtures.models.find((modelFixture) => {
|
||||
return modelFixture.name === 'Newsletter';
|
||||
});
|
||||
|
||||
fixtureManager.addFixturesForModel(newsletterFixtures).then(function (result) {
|
||||
should.exist(result);
|
||||
result.should.be.an.Object();
|
||||
result.should.have.property('expected', 1);
|
||||
result.should.have.property('done', 1);
|
||||
|
||||
newsletterOneStub.callCount.should.eql(1);
|
||||
newsletterAddStub.callCount.should.eql(1);
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('should not call add for main post fixture if it is already found', function (done) {
|
||||
const postOneStub = sinon.stub(models.Post, 'findOne').returns(Promise.resolve({}));
|
||||
const postAddStub = sinon.stub(models.Post, 'add').returns(Promise.resolve({}));
|
||||
|
@ -36,7 +36,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = 'ff2c43dc264d712397a912e9709a0410';
|
||||
const currentFixturesHash = 'f4dd2a454e1999b6d149cc26ae52ced4';
|
||||
const currentFixturesHash = 'dcc81e94da6fb9d96becf208cfa5bc73';
|
||||
const currentSettingsHash = '71fa38d0c805c18ceebe0fda80886230';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
||||
|
70
test/unit/server/services/auth/setup.test.js
Normal file
70
test/unit/server/services/auth/setup.test.js
Normal file
@ -0,0 +1,70 @@
|
||||
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'}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
@ -381,7 +381,7 @@ DataGenerator.Content = {
|
||||
show_header_icon: true,
|
||||
show_header_title: true,
|
||||
show_badge: true,
|
||||
sort_order: 0
|
||||
sort_order: 1
|
||||
},
|
||||
{
|
||||
id: ObjectId().toHexString(),
|
||||
@ -398,7 +398,7 @@ DataGenerator.Content = {
|
||||
show_header_icon: true,
|
||||
show_header_title: true,
|
||||
show_badge: true,
|
||||
sort_order: 0
|
||||
sort_order: 2
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -19,6 +19,16 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Newsletter",
|
||||
"entries": [
|
||||
{
|
||||
"name": "Default Newsletter",
|
||||
"slug": "default-newsletter",
|
||||
"sender_name": "Ghost"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tag",
|
||||
"entries": [
|
||||
|
Loading…
Reference in New Issue
Block a user