Skip to content

Commit

Permalink
Merge pull request #318 from elasticsales/collection-set-triggers-change
Browse files Browse the repository at this point in the history
failing test: change events should not fire on new items in Collection#set
  • Loading branch information
PaulUithol committed Apr 9, 2013
2 parents 4da5586 + 1e422d9 commit 9b52eb2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,33 @@ $(document).ready(function() {
equal( changedAttrs.color, 'red', '... with correct properties in "changedAttributes"' );
});

test( 'change events should not fire on new items in Collection#set', function() {
var changeEvents = 0;
var Foo = Backbone.RelationalModel.extend({
initialize: function(options) {
this.on( 'change', function(name) { changeEvents++; } );
this.on( 'change:id', function(name) { changeEvents++; } );
this.on( 'change:name', function(name) { changeEvents++; } );
this.on( 'all', function(name) {
if ( name.indexOf('change') === 0 ) {
changeEvents++;
}
});
}
});
var Foos = Backbone.Collection.extend({
model: Foo
});

var foos = new Foos();
foos.set( [{
id: 'foo-1',
name: 'foo'
}] );

equal( changeEvents, 0, 'no change events should be triggered' );
});


module( "Backbone.RelationalModel inheritance (`subModelTypes`)", { setup: reset } );

Expand Down

0 comments on commit 9b52eb2

Please sign in to comment.