Show notification on config save failures

Esse commit está contido em:
Kevin Sawicki
2015-02-05 15:34:17 -08:00
commit 30419027a8
2 arquivos alterados com 23 adições e 1 exclusões
+17
Ver Arquivo
@@ -666,6 +666,23 @@ describe "Config", ->
foo: foo:
bar: 'coffee' bar: 'coffee'
describe "when an error is thrown writing the file to disk", ->
addErrorHandler = null
beforeEach ->
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
it "creates a notification", ->
jasmine.unspy CSON, 'writeFileSync'
spyOn(CSON, 'writeFileSync').andCallFake ->
error = new Error()
error.code = 'EPERM'
error.path = atom.config.getUserConfigPath()
throw error
save = -> atom.config.save()
expect(save).not.toThrow()
expect(addErrorHandler.callCount).toBe 1
describe ".loadUserConfig()", -> describe ".loadUserConfig()", ->
beforeEach -> beforeEach ->
expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy() expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy()
+5
Ver Arquivo
@@ -868,7 +868,12 @@ class Config
save: -> save: ->
allSettings = {'*': @settings} allSettings = {'*': @settings}
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource(@getUserConfigPath()) allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource(@getUserConfigPath())
try
CSON.writeFileSync(@configFilePath, allSettings) CSON.writeFileSync(@configFilePath, allSettings)
catch error
message = "Failed to save `#{path.basename(@configFilePath)}`"
detail = error.message
@notifyFailure(message, detail)
### ###
Section: Private methods managing global settings Section: Private methods managing global settings