Skip to content

Commit

Permalink
Fixed new sites using "Default Product" Tier name
Browse files Browse the repository at this point in the history
TryGhost/Product#1289

Since we added the free Tier fixture, this was attempting to fix the
free Tier, rather than the default one.
  • Loading branch information
allouis committed Mar 10, 2022
1 parent f655ed3 commit 8229f80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions core/server/services/auth/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ async function doProduct(data, productsAPI) {
return user;
}
try {
const page = await productsAPI.browse({limit: 1});
const page = await productsAPI.browse({limit: 'all'});

const product = page.products.find(p => p.slug === 'default-product');

const [product] = page.products;
if (!product) {
return data;
}

productsAPI.edit({products: [{name: blogTitle.trim()}]}, {context: context.context, id: product.id});
await productsAPI.edit({products: [{name: blogTitle.trim()}]}, {context: context.context, id: product.id});
} catch (e) {
return data;
}
Expand Down
10 changes: 9 additions & 1 deletion test/regression/api/admin/authentication.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('Authentication API', function () {
agent = await agentProvider.getAdminAPIAgent();
});

beforeEach(function () {
beforeEach(async function () {
await mockManager.disableStripe();
mockManager.mockMail();
});

Expand Down Expand Up @@ -89,6 +90,13 @@ describe('Authentication API', function () {
.expect(({body}) => {
assert.deepEqual(body.notifications, [], 'The setup should not create notifications');
});

// 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');
});

it('is setup? yes', async function () {
Expand Down

0 comments on commit 8229f80

Please sign in to comment.