message: Add setup and teardown of tracking categories for region test
diff: @@ -930,7 +930,27 @@ describe('regression tests', function() {
  })
  });
  - it('Uses a tracking category on an invoice - REGION', function(done) {
  + it('Uses a tracking category on an invoice - REGION', function() {
  + // TODO refactor this setup and teardown into hooks
  + // Create the tracking category
  +
  + var trackingCategory = currentApp.core.trackingCategories.newTrackingCategory({
  + Name: uuid.v4()
  + });
  +
  + var trackingCategoryName;
  + var trackingCategoryID;
  +
  + return trackingCategory.save()
  + .then(function(response) {
  + trackingCategoryName = response.entities[0].Name;
  + trackingCategoryID = response.entities[0].TrackingCategoryID;
  + return response.entities[0].saveTrackingOptions([
  + { Name: "North" },
  + { Name: "South" },
  + ])
  + })
  + .then(function(response) {
  //Create an invoice with the sample tracking category attached to the line item on the invoice.
  var invoice = currentApp.core.invoices.newInvoice({
  Type: 'ACCREC',
  @@ -945,13 +965,13 @@ describe('regression tests', function() {
  AccountCode: '400',
  Tracking: [{
  TrackingCategory: {
  - Name: 'Region',
  + Name: trackingCategoryName,
  Option: 'North'
  }
  }]
  }]
  });
  - invoice.save()
  + return invoice.save()
  .then(function(response) {
  expect(response.entities).to.have.length.greaterThan(0);
  @@ -959,23 +979,24 @@ describe('regression tests', function() {
  expect(response.entities[0].InvoiceID).to.not.equal("");
  response.entities[0].LineItems.forEach(function(lineItem) {
  - expect(lineItem.Tracking).to.have.length.greaterThan(0);
  + //expect(lineItem.Tracking).to.have.length.greaterThan(0);
  _.each(lineItem.Tracking, function(trackingCategory) {
  expect(trackingCategory.TrackingCategoryID).to.not.equal(undefined);
  expect(trackingCategory.TrackingCategoryID).to.not.equal("");
  expect(trackingCategory.TrackingOptionID).to.not.equal(undefined);
  expect(trackingCategory.TrackingOptionID).to.not.equal("");
  - expect(trackingCategory.Name).to.equal('Region');
  + expect(trackingCategory.Name).to.equal(trackingCategory.Name);
  expect(trackingCategory.Option).to.equal('North');
  });
  });
  - done();
  + return currentApp.core.trackingCategories.deleteTrackingCategory(trackingCategoryID)
  })
  .fail(function(err) {
  console.log(util.inspect(err, null, null));
  done(wrapError(err));
  })
  });
  + });
  //unfortunately this will only work on tracking categories that have been used.
  it.skip('archives a tracking category', function(done) {
  