summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/deploy_keys/components/app.vue2
-rw-r--r--spec/javascripts/deploy_keys/components/app_spec.js15
2 files changed, 13 insertions, 4 deletions
diff --git a/app/assets/javascripts/deploy_keys/components/app.vue b/app/assets/javascripts/deploy_keys/components/app.vue
index a6552125e66..7315a9e11cb 100644
--- a/app/assets/javascripts/deploy_keys/components/app.vue
+++ b/app/assets/javascripts/deploy_keys/components/app.vue
@@ -66,7 +66,7 @@
},
beforeDestroy() {
eventHub.$off('enable.key', this.enableKey);
- eventHub.$off('remove.key', this.removeKey);
+ eventHub.$off('remove.key', this.disableKey);
eventHub.$off('disable.key', this.disableKey);
},
};
diff --git a/spec/javascripts/deploy_keys/components/app_spec.js b/spec/javascripts/deploy_keys/components/app_spec.js
index 43b8f718508..700897f50b0 100644
--- a/spec/javascripts/deploy_keys/components/app_spec.js
+++ b/spec/javascripts/deploy_keys/components/app_spec.js
@@ -116,15 +116,24 @@ describe('Deploy keys app component', () => {
expect(vm.service.disableKey).toHaveBeenCalledWith(key.id);
});
- it('calls disableKey when removing a key', () => {
+ it('calls disableKey when removing a key', (done) => {
const key = data.public_keys[0];
spyOn(window, 'confirm').and.returnValue(true);
- spyOn(vm, 'disableKey');
+ spyOn(vm.service, 'getKeys');
+ spyOn(vm.service, 'disableKey').and.callFake(() => new Promise((resolve) => {
+ resolve();
+
+ setTimeout(() => {
+ expect(vm.service.getKeys).toHaveBeenCalled();
+
+ done();
+ });
+ }));
eventHub.$emit('remove.key', key);
- expect(vm.disableKey).toHaveBeenCalledWith(key);
+ expect(vm.service.disableKey).toHaveBeenCalledWith(key.id);
});
it('hasKeys returns true when there are keys', () => {