476e2d53 by Adam Heath

First bug found with jasmine, Ordering.items was a globally shared

instance.
1 parent 2225231f
...@@ -3,9 +3,11 @@ define(function(require) { ...@@ -3,9 +3,11 @@ define(function(require) {
3 var Backbone = require('backbone'); 3 var Backbone = require('backbone');
4 4
5 var Ordering = Backbone.Model.extend({ 5 var Ordering = Backbone.Model.extend({
6 defaults: { 6 defaults: function defaults() {
7 return {
7 value: null, 8 value: null,
8 items: new Backbone.Collection(), 9 items: new Backbone.Collection(),
10 };
9 }, 11 },
10 initialize: function(data, options) { 12 initialize: function(data, options) {
11 if (this.get('value') === null) { 13 if (this.get('value') === null) {
......
1 define(function(require) {
2 'use strict';
3 var Backbone = require('backbone');
4 var Ordering = require('solr/model/Ordering');
5
6 describe('Ordering', function() {
7 it('loads', function() {
8 expect(Ordering).toBeDefined();
9 });
10 it('items are different instances', function() {
11 var o1 = new Ordering(), o2 = new Ordering();
12 expect(o1.get('items')).not.toBe(o2.get('items'));
13 });
14 });
15 });