Skip to content
Browse files

Merge pull request #318 from elasticsales/collection-set-triggers-change

failing test: change events should not fire on new items in Collection#set
  • Loading branch information...
2 parents 4da5586 + 1e422d9 commit 9b52eb220bb86a2da5e41c08e55b76a1f2108871 @PaulUithol committed Apr 9, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/tests.js
View
27 test/tests.js
@@ -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 } );

0 comments on commit 9b52eb2

Please sign in to comment.
Something went wrong with that request. Please try again.