mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Fixed #1413.
This commit is contained in:
parent
4cc79e985e
commit
88252806c7
2 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
19
test/app/views/editor/PatchModal.spec.coffee
Normal file
19
test/app/views/editor/PatchModal.spec.coffee
Normal 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)
|
Loading…
Reference in a new issue