old_contents: /* global beforeEach, describe, expect, it */
  'use strict';
  
  import { Model } from 'ponyjs/models/base.js';
  import { NestedRelatedField, RelationDescriptor } from 'ponyjs/models/fields/related.js';
  
  
  let Brand = Model('Brand');
  let Kit = Model('Kit', {
      brand: new NestedRelatedField(Brand)
  });
  
  
  
  let generateResponse = function(object, status=200) {
      return [
          status,
          {'Content-type': 'application/json'},
          JSON.stringify(object)
      ];
  }
  
  
  describe('The base relation descriptor', () => {
  
      it('should throw on getter/setter access', () => {
          let descriptor = new RelationDescriptor(null, null);
          expect(() => descriptor.get(null)).to.throw(Error, 'Not implemented');
          expect(() => descriptor.set(null, null)).to.throw(Error, 'Not implemented');
      });
  
  });
  
  
  describe('Models with relation fields', () => {
  
      let server = null;
  
      beforeEach(() => {
          server = sinon.fakeServer.create();
          server.autoRespond = true;
          server.xhr.useFilters = true;
  
          server.xhr.addFilter(function (method, uri) {
              let matched = uri.startsWith('http://example.com') || uri.startsWith('http://api.external.com');
              // Sinon FakeXHR filters need to return `false` if the request should be stubbed and
              // `true` if it should be allowed to pass through.
              return !matched;
          });
      });
  
      afterEach(() => {
          server.restore();
      });
  
      it('should return null if the nested data is not present', () => {
          let kit = new Kit({id: 1});
          let kit2 = new Kit({id: 2, brand: null});
          expect(kit.brand).to.be.null;
          // check that second access returns the same instance
          let brand = kit.brand;
          expect(kit.brand).to.equal(brand);
          expect(kit2.brand).to.be.null;
      });
  
      it('should instantiate nested foreign keys', () => {
          let kit = new Kit({
              id: 1,
              brand: {
                  id: 2
              }
          });
          expect(kit.brand).to.be.instanceOf(Brand);
          expect(kit.brand).to.deep.equal({id: 2});
      });
  
      it('should resolve nested foreign keys', () => {
          let rawKit = {
              "id": 1,
              "name": "S100 & Flak 38 Schnellboot",
              "kit_number": "",
              "box_image": {
                  "small": null
              },
              "brand": {
                  "id": 2,
                  "name": "Revell",
                  "is_active": true,
                  "logo": {
                      "small": "http://example.com/media/image.jpg"
                  }
              }
          };
          var okResponse = generateResponse(rawKit);
          server.respondWith('GET', 'http://example.com/api/v1/kit/1/', okResponse);
          let expectedBrand = new Brand({"id": 2,
              "name": "Revell",
              "is_active": true,
              "logo": {
                  "small": "http://example.com/media/image.jpg"
              }
          });
          return Kit.objects.get({id: 1}).should
              .eventually.be.an.instanceof(Kit)
              .and.satisfy(kit => {
                  return (kit.brand instanceof Brand);
              });
      });
  });
  
new_contents: /* global beforeEach, describe, expect, it */
  'use strict';
  
  import { Model } from 'ponyjs/models/base.js';
  import { NestedRelatedField, RelationDescriptor } from 'ponyjs/models/fields/related.js';
  
  
  let Brand = Model('Brand');
  let Kit = Model('Kit', {
      brand: new NestedRelatedField(Brand)
  });
  
  
  describe('The base relation descriptor', () => {
  
      it('should throw on getter/setter access', () => {
          let descriptor = new RelationDescriptor(null, null);
          expect(() => descriptor.get(null)).to.throw(Error, 'Not implemented');
          expect(() => descriptor.set(null, null)).to.throw(Error, 'Not implemented');
      });
  
  });
  
  
  describe('Models with relation fields', () => {
  
      it('should return null if the nested data is not present', () => {
          let kit = new Kit({id: 1});
          let kit2 = new Kit({id: 2, brand: null});
          expect(kit.brand).to.be.null;
          // check that second access returns the same instance
          let brand = kit.brand;
          expect(kit.brand).to.equal(brand);
          expect(kit2.brand).to.be.null;
      });
  
      it('should instantiate nested foreign keys', () => {
          let kit = new Kit({
              id: 1,
              brand: {
                  id: 2
              }
          });
          expect(kit.brand).to.be.instanceOf(Brand);
          expect(kit.brand).to.deep.equal({id: 2});
      });
  
  });
  
subject: Remove some testing cruft