Use Atom::replicate in git spec to simulate project serialization

This commit is contained in:
Kevin Sawicki 2013-11-14 12:37:22 -08:00
parent 8b17b7eca9
commit 7b43c8a860
4 changed files with 14 additions and 3 deletions

View File

@ -257,7 +257,8 @@ describe "Git", ->
it "subscribes to all the serialized buffers in the project", ->
project.openSync('sample.js')
project2 = deserialize(project.serialize())
#TODO Replace with atom.replicate().project when Atom is a telepath model
project2 = atom.replicate().get('project')
buffer = project2.getBuffers()[0]
waitsFor ->

View File

@ -317,6 +317,10 @@ class Atom
else
@windowState
# Private: Returns a replicated copy of the current state.
replicate: ->
@windowState.replicate()
crashMainProcess: ->
remote.process.crash()

View File

@ -71,8 +71,7 @@ class Git
@refreshStatus()
if project?
@subscribeToBuffer(buffer) for buffer in project.getBuffers()
@subscribe project, 'buffer-created', (buffer) => @subscribeToBuffer(buffer)
@subscribe project.buffers.onEach (buffer) => @subscribeToBuffer(buffer)
# Private: Subscribes to buffer events.
subscribeToBuffer: (buffer) ->

View File

@ -34,6 +34,11 @@ class TextBuffer extends Model
file: null
refcount: 0
constructor: ->
super
@loadWhenAttached = @getState()?
# Private: Called by telepath
attached: ->
@loaded = false
@ -45,6 +50,8 @@ class TextBuffer extends Model
@setPath(@filePath)
@load() if @loadWhenAttached
# Private: Called by telepath
beforePersistence: ->
@modifiedWhenLastPersisted = @isModified()