mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
🐛 fix issue with re-uploading a deleted theme (#725)
closes https://github.com/TryGhost/Ghost/issues/8515 - ensure the theme record is removed from the store when deleting because theme IDs get re-used unlike other models
This commit is contained in:
parent
f1f1580084
commit
1d4cc70246
@ -73,7 +73,12 @@ export default Controller.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
return theme.destroyRecord().catch((error) => {
|
||||
return theme.destroyRecord().then(() => {
|
||||
// HACK: this is a private method, we need to unload from the store
|
||||
// here so that uploading another theme with the same "id" doesn't
|
||||
// attempt to update the deleted record
|
||||
theme.unloadRecord();
|
||||
}).catch((error) => {
|
||||
this.get('notifications').showAPIError(error);
|
||||
});
|
||||
},
|
||||
|
@ -651,5 +651,31 @@ describe('Acceptance: Settings - Design', function () {
|
||||
// restore default mirage handlers
|
||||
mockThemes(server);
|
||||
});
|
||||
|
||||
it('can delete then re-upload the same theme', async function () {
|
||||
server.loadFixtures('themes');
|
||||
|
||||
// mock theme upload to emulate uploading theme with same id
|
||||
server.post('/themes/upload/', function ({themes}) {
|
||||
let theme = themes.create({
|
||||
name: 'foo',
|
||||
package: {
|
||||
name: 'Foo',
|
||||
version: '0.1'
|
||||
}
|
||||
});
|
||||
|
||||
return {themes: [theme]};
|
||||
});
|
||||
|
||||
await visit('/settings/design');
|
||||
await click(`${testSelector('theme-id', 'foo')} ${testSelector('theme-delete-button')}`);
|
||||
await click(`.fullscreen-modal ${testSelector('delete-button')}`);
|
||||
|
||||
await click(testSelector('upload-theme-button'));
|
||||
await fileUpload('.fullscreen-modal input[type="file"]', ['test'], {name: 'foo.zip', type: 'application/zip'});
|
||||
// this will fail if upload failed because there won't be an activate now button
|
||||
await click(`.fullscreen-modal ${testSelector('activate-now-button')}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user