0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fix teardown of gh-profile-image when fileStorage=false

closes #6253
- don't expect the file input to be present in `willDestroyElement`
This commit is contained in:
Kevin Ansfield 2015-12-21 11:08:49 +00:00
parent 968349236d
commit cb921a951e
2 changed files with 15 additions and 2 deletions

View file

@ -88,10 +88,12 @@ export default Component.extend({
}, },
willDestroyElement() { willDestroyElement() {
let $input = this.$('.js-file-input');
this._super(...arguments); this._super(...arguments);
if (this.$('.js-file-input').data()['blueimp-fileupload']) { if ($input.length && $input.data()['blueimp-fileupload']) {
this.$('.js-file-input').fileupload('destroy'); $input.fileupload('destroy');
} }
}, },

View file

@ -43,6 +43,17 @@ describeComponent(
expect(this.$()).to.have.length(1); expect(this.$()).to.have.length(1);
}); });
it('renders and tears down ok with fileStorage:false', function () {
this.set('fileStorage', false);
this.render(hbs`
{{gh-profile-image fileStorage=fileStorage}}
`);
expect(this.$()).to.have.length(1);
expect(this.$('input')).to.have.length(0);
}),
it('immediately renders the gravatar if valid email supplied', function () { it('immediately renders the gravatar if valid email supplied', function () {
let email = 'test@example.com'; let email = 'test@example.com';
let expectedUrl = `http://www.gravatar.com/avatar/${md5(email)}?s=100&d=blank`; let expectedUrl = `http://www.gravatar.com/avatar/${md5(email)}?s=100&d=blank`;