mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Handled null trial days on tiers
refs e26c977c66
- handles null trial days in admin and API, sets trial days as 0 for null values
This commit is contained in:
parent
98b21d18f9
commit
ce80d250bf
3 changed files with 18 additions and 2 deletions
|
@ -14,6 +14,6 @@ export default Model.extend(ValidationEngine, {
|
|||
currency: attr('string'),
|
||||
monthlyPrice: attr('number'),
|
||||
yearlyPrice: attr('number'),
|
||||
trialDays: attr('number'),
|
||||
trialDays: attr('number', {defaultValue: 0}),
|
||||
benefits: attr('tier-benefits')
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ function convertTierInput(input) {
|
|||
};
|
||||
|
||||
if (labs.isSet('freeTrial')) {
|
||||
converted.trial_days = input.trial_days;
|
||||
converted.trial_days = input.trial_days || 0;
|
||||
}
|
||||
|
||||
if (input.monthly_price && input.currency) {
|
||||
|
|
|
@ -110,4 +110,20 @@ describe('Tiers API', function () {
|
|||
|
||||
assert(updatedTier.visibility === visibility, `The visibility of the Tier should have been updated to ${visibility}`);
|
||||
});
|
||||
|
||||
it('Can save with trial_days as null', async function () {
|
||||
const {body: {tiers: [tier]}} = await agent.get('/tiers/?limit=1');
|
||||
|
||||
await agent.put(`/tiers/${tier.id}/`)
|
||||
.body({
|
||||
tiers: [{
|
||||
trial_days: null
|
||||
}]
|
||||
})
|
||||
.expectStatus(200);
|
||||
|
||||
const {body: {tiers: [updatedTier]}} = await agent.get(`/tiers/${tier.id}/`);
|
||||
|
||||
assert(updatedTier.trial_days === 0, `The trial_days should have been set to 0`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue