diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 3477acc52..ac6e1d26f 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -383,6 +383,25 @@ describe "Pane", -> pane.saveActiveItem() expect(atom.showSaveDialogSync).not.toHaveBeenCalled() + describe "when the item's saveAs method throws a well-known IO error", -> + notificationSpy = null + beforeEach -> + atom.notifications.onDidAddNotification notificationSpy = jasmine.createSpy() + + it "creates a notification", -> + pane.getActiveItem().saveAs = -> + error = new Error("EACCES, permission denied '/foo'") + error.path = '/foo' + error.code = 'EACCES' + throw error + + pane.saveActiveItem() + expect(notificationSpy).toHaveBeenCalled() + notification = notificationSpy.mostRecentCall.args[0] + expect(notification.getType()).toBe 'warning' + expect(notification.getMessage()).toContain 'Permission denied' + expect(notification.getMessage()).toContain '/foo' + describe "::saveActiveItemAs()", -> pane = null @@ -404,6 +423,25 @@ describe "Pane", -> pane.saveActiveItemAs() expect(atom.showSaveDialogSync).not.toHaveBeenCalled() + describe "when the item's saveAs method throws a well-known IO error", -> + notificationSpy = null + beforeEach -> + atom.notifications.onDidAddNotification notificationSpy = jasmine.createSpy() + + it "creates a notification", -> + pane.getActiveItem().saveAs = -> + error = new Error("EACCES, permission denied '/foo'") + error.path = '/foo' + error.code = 'EACCES' + throw error + + pane.saveActiveItemAs() + expect(notificationSpy).toHaveBeenCalled() + notification = notificationSpy.mostRecentCall.args[0] + expect(notification.getType()).toBe 'warning' + expect(notification.getMessage()).toContain 'Permission denied' + expect(notification.getMessage()).toContain '/foo' + describe "::itemForURI(uri)", -> it "returns the item for which a call to .getURI() returns the given uri", -> pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C"), new Item("D")]) diff --git a/src/pane.coffee b/src/pane.coffee index f236d14ab..aef4b2aff 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -502,6 +502,7 @@ class Pane extends Model newItemPath = atom.showSaveDialogSync(itemPath) if newItemPath try + console.log 'here?' item.saveAs(newItemPath) catch error @handleSaveError(error)