This commit is contained in:
Scott Erickson 2014-08-11 18:47:00 -07:00
parent 4cc79e985e
commit 88252806c7
2 changed files with 22 additions and 0 deletions

View file

@ -220,6 +220,9 @@ class CocoModel extends Backbone.Model
catch error
console.error 'Error applying delta\n', JSON.stringify(delta, null, '\t'), '\n\nto attributes\n\n', newAttributes
return false
for key, value of newAttributes
delete newAttributes[key] if _.isEqual value, @attributes[key]
@set newAttributes
return true

View file

@ -0,0 +1,19 @@
LevelComponent = require 'models/LevelComponent'
Patch = require 'models/Patch'
PatchModal = require 'views/editor/PatchModal'
describe 'PatchModal', ->
describe 'acceptPatch', ->
it 'triggers LevelComponents and Systems to recompile their code', ->
levelComponent = new LevelComponent({ code: 'newList = (item.prop for item in list)', id: 'id' })
levelComponent.markToRevert()
levelComponent.set('code', 'func = -> console.log()')
patch = new Patch({delta: levelComponent.getDelta(), target: 'id'})
levelComponent = new LevelComponent({ code: 'newList = (item.prop for item in list)', id: 'id' })
levelComponent.markToRevert()
patchModal = new PatchModal(patch, levelComponent)
patchModal.render()
patchModal.acceptPatch()
expect(levelComponent.get('js').indexOf('function()')).toBeGreaterThan(-1)