Merge pull request #5768 from atom/mb-save-state-based-on-project-paths

Base state path on project paths
This commit is contained in:
Max Brunsfeld
2015-02-26 11:55:17 -08:00
2 changed files with 33 additions and 6 deletions

View File

@@ -3,6 +3,8 @@ Exec = require('child_process').exec
path = require 'path'
Package = require '../src/package'
ThemeManager = require '../src/theme-manager'
_ = require "underscore-plus"
temp = require "temp"
describe "the `atom` global", ->
describe 'window sizing methods', ->
@@ -124,3 +126,29 @@ describe "the `atom` global", ->
line: 2
column: 3
originalError: error
describe "saving and loading", ->
afterEach -> atom.mode = "spec"
it "selects the state based on the current project paths", ->
Atom = atom.constructor
[dir1, dir2] = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]
loadSettings = _.extend Atom.getLoadSettings(),
initialPaths: [dir1]
windowState: null
spyOn(Atom, 'getLoadSettings').andCallFake -> loadSettings
spyOn(Atom, 'getStorageDirPath').andReturn(temp.mkdirSync("storage-dir-"))
atom.mode = "editor"
atom.state.stuff = "cool"
atom.project.setPaths([dir1, dir2])
atom.saveSync.originalValue.call(atom)
atom1 = Atom.loadOrCreate("editor")
expect(atom1.state.stuff).toBeUndefined()
loadSettings.initialPaths = [dir1, dir2]
atom2 = Atom.loadOrCreate("editor")
expect(atom2.state.stuff).toBe("cool")