mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Handled default product to use first paid product
Since we now have 2 products by default for all ghost sites, free and default paid, the usage of default product which so far was using first product needs to be updated to use the first paid product. - updates default product usage to use first paid tier - updates tests
This commit is contained in:
parent
345eb5828c
commit
62777d7f26
8 changed files with 45 additions and 17 deletions
|
@ -28,7 +28,9 @@ function calculateLegacyPriceData(products) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProduct = products[0] || {};
|
const defaultProduct = products.find((product) => {
|
||||||
|
return product.type === 'paid';
|
||||||
|
}) || {};
|
||||||
|
|
||||||
const monthlyPrice = makePriceObject(defaultProduct.monthly_price || defaultPrice);
|
const monthlyPrice = makePriceObject(defaultProduct.monthly_price || defaultPrice);
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,9 @@ const getPortalProductPrices = async function () {
|
||||||
prices: productPrices
|
prices: productPrices
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const defaultProduct = products[0];
|
const defaultProduct = products.find((product) => {
|
||||||
|
return product.type === 'paid';
|
||||||
|
});
|
||||||
const defaultPrices = defaultProduct ? defaultProduct.prices : [];
|
const defaultPrices = defaultProduct ? defaultProduct.prices : [];
|
||||||
let portalProducts = defaultProduct ? [defaultProduct] : [];
|
let portalProducts = defaultProduct ? [defaultProduct] : [];
|
||||||
if (labsService.isSet('multipleProducts')) {
|
if (labsService.isSet('multipleProducts')) {
|
||||||
|
|
|
@ -24,7 +24,8 @@ describe('MemberStripeCustomer Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
@ -126,7 +127,8 @@ describe('MemberStripeCustomer Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
|
|
@ -30,7 +30,8 @@ describe('Member Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
@ -188,7 +189,8 @@ describe('Member Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
@ -271,14 +273,16 @@ describe('Member Model', function run() {
|
||||||
it('Products can be created & added to members by the product array', async function () {
|
it('Products can be created & added to members by the product array', async function () {
|
||||||
const context = testUtils.context.admin;
|
const context = testUtils.context.admin;
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Product-Add-Test'
|
name: 'Product-Add-Test',
|
||||||
|
type: 'paid'
|
||||||
});
|
});
|
||||||
const member = await Member.add({
|
const member = await Member.add({
|
||||||
email: 'testing-products@test.member',
|
email: 'testing-products@test.member',
|
||||||
products: [{
|
products: [{
|
||||||
id: product.id
|
id: product.id
|
||||||
}, {
|
}, {
|
||||||
name: 'Product-Create-Test'
|
name: 'Product-Create-Test',
|
||||||
|
type: 'paid'
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
...context,
|
...context,
|
||||||
|
@ -311,7 +315,8 @@ describe('Member Model', function run() {
|
||||||
email: 'filter-test@test.member',
|
email: 'filter-test@test.member',
|
||||||
products: [{
|
products: [{
|
||||||
name: 'VIP',
|
name: 'VIP',
|
||||||
slug: 'vip'
|
slug: 'vip',
|
||||||
|
type: 'paid'
|
||||||
}]
|
}]
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
|
@ -355,7 +360,8 @@ describe('Member Model', function run() {
|
||||||
email: 'name-filter-test@test.member',
|
email: 'name-filter-test@test.member',
|
||||||
products: [{
|
products: [{
|
||||||
name: 'VIP',
|
name: 'VIP',
|
||||||
slug: 'vip'
|
slug: 'vip',
|
||||||
|
type: 'paid'
|
||||||
}]
|
}]
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
|
@ -378,7 +384,8 @@ describe('Member Model', function run() {
|
||||||
email: 'email-filter-test@test.member',
|
email: 'email-filter-test@test.member',
|
||||||
products: [{
|
products: [{
|
||||||
name: 'VIP',
|
name: 'VIP',
|
||||||
slug: 'vip'
|
slug: 'vip',
|
||||||
|
type: 'paid'
|
||||||
}]
|
}]
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
|
@ -404,7 +411,8 @@ describe('Member Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
|
|
@ -26,7 +26,8 @@ describe('StripeCustomerSubscription Model', function run() {
|
||||||
|
|
||||||
const product = await Product.add({
|
const product = await Product.add({
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
await StripeProduct.add({
|
await StripeProduct.add({
|
||||||
|
|
|
@ -35,8 +35,8 @@ const validateRouteSettings = require('../../../../../core/server/services/route
|
||||||
*/
|
*/
|
||||||
describe('DB version integrity', function () {
|
describe('DB version integrity', function () {
|
||||||
// Only these variables should need updating
|
// Only these variables should need updating
|
||||||
const currentSchemaHash = 'e649797a5de92d417744f6f2623c79cf';
|
const currentSchemaHash = '56769494697fb27c189c63e3e8a228e9';
|
||||||
const currentFixturesHash = '07d4b0c4cf159b34344a6b5e88c74e9f';
|
const currentFixturesHash = 'e1d5e5d493aa1b01498505e75ce73e56';
|
||||||
const currentSettingsHash = 'd73b63e33153c9256bca42ebfd376779';
|
const currentSettingsHash = 'd73b63e33153c9256bca42ebfd376779';
|
||||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||||
|
|
||||||
|
|
|
@ -366,10 +366,17 @@ DataGenerator.Content = {
|
||||||
],
|
],
|
||||||
|
|
||||||
products: [
|
products: [
|
||||||
|
{
|
||||||
|
id: ObjectId().toHexString(),
|
||||||
|
name: 'Free',
|
||||||
|
slug: 'free',
|
||||||
|
type: 'free'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: ObjectId().toHexString(),
|
id: ObjectId().toHexString(),
|
||||||
name: 'Ghost Product',
|
name: 'Ghost Product',
|
||||||
slug: 'ghost-product'
|
slug: 'ghost-product',
|
||||||
|
type: 'paid'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
"entries": [
|
"entries": [
|
||||||
{
|
{
|
||||||
"name": "Default Product",
|
"name": "Default Product",
|
||||||
"slug": "default-product"
|
"slug": "default-product",
|
||||||
|
"type": "paid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Free",
|
||||||
|
"slug": "free",
|
||||||
|
"type": "free"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue