Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simpler test added for `merge: true` on Collection.reset.

Revert "Merge pull request #320 from elasticsales/collection-set-vs-reset"

This reverts commit c31ea90, reversing
changes made to 9b52eb2.
  • Loading branch information...
commit 904875040b46ad21f6a698170ff73d90e1ae0486 1 parent 77eb89d
@PaulUithol authored
Showing with 0 additions and 63 deletions.
  1. +0 −63 test/tests.js
View
63 test/tests.js
@@ -297,30 +297,9 @@ $(document).ready(function() {
}
});
- window.Country = Backbone.RelationalModel.extend();
- window.CountryCollection = Backbone.Collection.extend({
- model: Country
- });
-
window.Address = Backbone.RelationalModel.extend({
urlRoot: '/address/',
- relations: [{
- type: Backbone.HasOne,
- key: 'country',
- keySource: 'country_id',
- relatedModel: 'Country'
- }
- ],
-
- initialize: function(attributes, options) {
- // initialize an empty object if we don't already have one
- // as an alternative to fetchRelated()
- if ( attributes.country_id && !this.get('country') ) {
- this.set('country', Country.findOrCreate( { id: attributes.country_id } ));
- }
- },
-
toString: function() {
return 'Address (' + this.id + ')';
}
@@ -1259,48 +1238,6 @@ $(document).ready(function() {
ok( contact === contacts.first(), '... and same model instances' );
});
- test( "object gets related object linked properly when loaded using Collection#set", function() {
- var countries = new CountryCollection();
-
- // create address
- var address = new Address({
- id: 'address-1',
- country_id: 'US'
- });
- var country = address.get( 'country' );
- ok( country, 'address country exists' );
- ok( country.id, '... with valid id' );
- ok( !country.has('name'), '... without a name yet' );
- ok( country instanceof Country, '... and is instanceof Country' );
-
- // then countries fetch completes... if using SET
- countries.set( [ { id: 'US', name: 'United States' } ] );
- var country2 = address.get( 'country' );
- ok( country === country2, 'after reset, address country is the same instance' );
- equal( country.get('name'), 'United States', '... but now it has all the attributes' );
- });
-
- test( "object gets related object linked properly when loaded using Collection#reset", function() {
- var countries = new CountryCollection();
-
- // create address
- var address = new Address({
- id: 'address-1',
- country_id: 'US'
- });
- var country = address.get( 'country' );
- ok( country, 'address country exists' );
- ok( country.id, '... with valid id' );
- ok( !country.has('name'), '... without a name yet' );
- ok( country instanceof Country, '... and is instanceof Country' );
-
- // then countries fetch completes... if using RESET
- countries.reset( [ { id: 'US', name: 'United States' } ] );
- var country2 = address.get( 'country' );
- ok( country === country2, 'after reset, address country is the same instance' );
- equal( country.get('name'), 'United States', '... but now it has all the attributes' );
- });
-
test( "constructor.findOrCreate", function() {
var personColl = Backbone.Relational.store.getCollection( person1 ),
origPersonCollSize = personColl.length;
Please sign in to comment.
Something went wrong with that request. Please try again.