From 60841e574a715e4e0609ada1180698da53df392d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 11 Nov 2015 18:18:55 +0100 Subject: [PATCH] Make sure showing errors works correctly --- spec/command-installer-spec.coffee | 26 ++++++++++++++++++++++++-- src/command-installer.coffee | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/spec/command-installer-spec.coffee b/spec/command-installer-spec.coffee index 584dc193e..221da3a8b 100644 --- a/spec/command-installer-spec.coffee +++ b/spec/command-installer-spec.coffee @@ -20,10 +20,32 @@ describe "CommandInstaller on #darwin", -> spyOn(CommandInstaller::, 'getResourcesDirectory').andReturn(resourcesPath) spyOn(CommandInstaller::, 'getInstallDirectory').andReturn(installationPath) + it "shows an error dialog when installing commands interactively fails", -> + appDelegate = jasmine.createSpyObj("appDelegate", ["confirm"]) + installer = new CommandInstaller("2.0.2", appDelegate) + spyOn(installer, "installAtomCommand").andCallFake (__, callback) -> callback(new Error("an error")) + + installer.installShellCommandsInteractively() + + expect(appDelegate.confirm).toHaveBeenCalledWith({ + message: "Failed to install shell commands" + detailedMessage: "an error" + }) + + appDelegate.confirm.reset() + installer.installAtomCommand.andCallFake (__, callback) -> callback() + spyOn(installer, "installApmCommand").andCallFake (__, callback) -> callback(new Error("another error")) + + installer.installShellCommandsInteractively() + + expect(appDelegate.confirm).toHaveBeenCalledWith({ + message: "Failed to install shell commands" + detailedMessage: "another error" + }) + describe "when using a stable version of atom", -> beforeEach -> - confirm = -> - installer = new CommandInstaller("2.0.2", confirm) + installer = new CommandInstaller("2.0.2") it "symlinks the atom command as 'atom'", -> installedAtomPath = path.join(installationPath, 'atom') diff --git a/src/command-installer.coffee b/src/command-installer.coffee index 5a6a7f94e..e37e6a0e6 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -35,7 +35,7 @@ class CommandInstaller process.resourcesPath installShellCommandsInteractively: -> - showErrorDialog = (error) -> + showErrorDialog = (error) => @applicationDelegate.confirm message: "Failed to install shell commands" detailedMessage: error.message