Permalink
Browse files

Merge branch 'master' into 19735

  • Loading branch information...
John Rogelstad
John Rogelstad committed Mar 19, 2013
2 parents 3bb63f1 + 37d45db commit fc0f6fe00d93c073b5882f25fc4f5915cea0cedb
@@ -62,9 +62,8 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
that are older than the number of hours set in the hourLifespan variable. */
fetchOptions.success = function () {
for (var i = 0; i < bicacheCollection.length; i++) {
- date = bicacheCollection.models[i].get("created");
- date = date.getTime();
- dateDifference = currentDate - date;
+ date = new Date(bicacheCollection.models[i].get("created"));
+ dateDifference = currentDate - date.getTime();
if (dateDifference > (1000 * 60 * 60 * hourLifespan)) {
bicacheCollection.models[i].destroy();
}
@@ -5,6 +5,7 @@ white:true*/
setTimeout:true, clearTimeout: true, exports: true */
var _ = require("underscore"),
+ zombieAuth = require("./zombie_auth"),
assert = require("assert");
(function () {
@@ -23,7 +24,7 @@ var _ = require("underscore"),
@param {Object} Data
@param {Object} Vows
*/
- exports.create = function (data, vows) {
+ var create = exports.create = function (data, vows) {
vows = vows || {};
var context = {
topic: function () {
@@ -80,7 +81,7 @@ var _ = require("underscore"),
@param {Object} Data
@param {Object} Vows
*/
- exports.save = function (data, vows) {
+ var save = exports.save = function (data, vows) {
vows = vows || {};
var context = {
topic: function () {
@@ -144,7 +145,7 @@ var _ = require("underscore"),
@param {Object} Data
@param {Object} Vows
*/
- exports.update = function (data, vows) {
+ var update = exports.update = function (data, vows) {
vows = vows || {};
var context = {
topic: function () {
@@ -168,7 +169,7 @@ var _ = require("underscore"),
@param {Data}
@param {Object} Vows
*/
- exports.destroy = function (data, vows) {
+ var destroy = exports.destroy = function (data, vows) {
vows = vows || {};
var context = {
topic: function () {
@@ -205,4 +206,52 @@ var _ = require("underscore"),
return context;
};
+ /**
+ String all CRUD tests together so that simple models can be
+ tested with a single function
+ */
+ var runAllCrud = exports.runAllCrud = function (data) {
+ var context = {
+ topic: function () {
+ var that = this,
+ callback = function () {
+ data.model = new XM[data.recordType.substring(3)]();
+ that.callback(null, data);
+ };
+ zombieAuth.loadApp({callback: callback, verbose: false});
+ },
+ 'Verify the record type is correct': function (data) {
+ assert.equal(data.model.recordType, data.recordType);
+ },
+ 'We can create a model ': create(data, {
+ '-> Set values to the model': {
+ topic: function (data) {
+ data.model.set(data.createHash);
+ return data;
+ },
+ // create vows
+ 'Verify the last error is null': function (data) {
+ assert.isNull(data.model.lastError);
+ },
+ '-> Save the model': save(data, {
+ 'We can update the model ': update(data, {
+ '-> Set values': {
+ topic: function () {
+ data.model.set(data.updateHash);
+ return data;
+ },
+ '-> Commit to the model': save(data, {
+ 'destroy': destroy(data)
+ })
+ }
+ })
+ })
+ }
+ })
+ };
+ return context;
+ };
+
+
+
}());
@@ -6,6 +6,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
XT = {};
XM = {};
XV = {};
+XZ = {}; // xTuple Zombie. Used to help zombie within the context of these tests.
var assert = require('assert'),
zombie = require('zombie');
@@ -83,7 +84,7 @@ Simplest possible usage:
if (verboseMode) {
console.log("Using pre-existing zombie session");
}
- callback(); // TODO: callback(XZ.browser);
+ callback();
return;
}
@@ -122,6 +123,7 @@ Simplest possible usage:
XM = browser.window.XM;
XT = browser.window.XT;
XV = browser.window.XV;
+ XZ.browser = browser;
XT.log = function (message) {
// log if verbose mode or if the log is an error
@@ -136,7 +138,7 @@ Simplest possible usage:
clearTimeout(timeout);
// give control back to whoever called us
- callback(/*browser*/); // XXX needed for route tests but creates an unspecified error now???
+ callback();
}
}, 100); // 100 = check to see if the app is loaded every 0.1 seconds
});
@@ -20,7 +20,7 @@ var XVOWS = XVOWS || {};
number: "MIKECUST",
customerType: 19,
terms: 42,
- salesRep: 29,
+ //salesRep: must be fetched
backorder: true,
partialShip: true,
discount: 0,
@@ -59,6 +59,17 @@ var XVOWS = XVOWS || {};
'CREATE ': crud.create(data, {
'-> Set values': {
topic: function (data) {
+ var that = this,
+ fetchOptions = {},
+ rep = new XM.SalesRep();
+ fetchOptions.id = 30;
+ fetchOptions.success = function () {
+ data.model.set('salesRep', rep);
+ };
+ fetchOptions.error = function () {
+ that.callback("Error fetching a SalesRep");
+ };
+ rep.fetch(fetchOptions);
data.model.set(data.createHash);
return data;
},
@@ -8,65 +8,20 @@ var XVOWS = XVOWS || {};
"use strict";
var vows = require("vows"),
- assert = require("assert"),
- zombieAuth = require("../lib/zombie_auth"),
- crud = require('../lib/crud');
-
- var data = {};
-
- data.createHash = {
- code: "Herr"
- };
-
- data.updateHash = {
- code: "Dame"
- };
-
- vows.describe('XM.Honorific CRUD test').addBatch({
- 'We can INITIALIZE a Honorific Model ': {
- topic: function () {
- var that = this,
- callback = function () {
- data.model = new XM.Honorific();
- that.callback(null, data);
- };
- zombieAuth.loadApp({callback: callback, verbose: false});
+ crud = require('../lib/crud'),
+ data = {
+ recordType: "XM.Honorific",
+ autoTestAttributes: true,
+ createHash: {
+ code: "Herr"
},
- 'Verify the record type is XM.Honorific': function (data) {
- assert.equal(data.model.recordType, "XM.Honorific");
+ updateHash: {
+ code: "Dame"
}
- }
- }).addBatch({
- 'We can CREATE a Honorific Model ': crud.create(data, {
- '-> Set values to the Honorific': {
- topic: function (data) {
- data.model.set(data.createHash);
- return data;
- },
- 'Verify Last Error is null': function (data) {
- assert.isNull(data.model.lastError);
- },
- '-> Save the Honorific': crud.save(data)
- }
- })
- }).addBatch({
- 'We can READ the Honorific': {
- topic: function () {
- return data;
- }
- }
- }).addBatch({
- 'We can UPDATE the Honorific ': crud.update(data, {
- '-> Set values': {
- topic: function () {
- data.model.set(data.updateHash);
- return data;
- },
- '-> Commit to the Honorific': crud.save(data)
- }
- })
- }).addBatch({
- 'We can DESTROY a Honorific Model': crud.destroy(data)
+ };
+
+ vows.describe('XM.Honorific CRUD test').addBatch({
+ 'We can run the XM.Honorific CRUD tests ': crud.runAllCrud(data)
}).export(module);
}());
@@ -9,75 +9,27 @@ var XVOWS = XVOWS || {};
var vows = require("vows"),
assert = require("assert"),
- zombieAuth = require("../lib/zombie_auth"),
- crud = require('../lib/crud');
-
- var data = {};
-
- data.autoTestAttributes = true;
-
- data.createHash = {
- item: {id: 333},
- site: {id: 37}, // NOTE the item and site have to be a combo that doesn't yet exist
- plannerCode: {id: 27, code: "NONE"},
- costCategory: {id: 30, code: "FINISHED"},
- isSold: false
- };
-
- data.updateHash = {
- isSold: true
- };
-
- vows.describe('XM.ItemSite CRUD test').addBatch({
- 'INITIALIZE ': {
- topic: function () {
- var that = this,
- callback = function () {
- data.model = new XM.ItemSite();
- that.callback(null, data);
- };
- zombieAuth.loadApp({callback: callback, verbose: false});
+ crud = require('../lib/crud'),
+ data = {
+ recordType: "XM.ItemSite",
+ autoTestAttributes: true,
+ createHash: {
+ item: {id: 333},
+ site: {id: 37}, // NOTE the item and site have to be a combo that doesn't yet exist
+ plannerCode: {id: 27, code: "NONE"},
+ costCategory: {id: 30, code: "FINISHED"},
+ isSold: false
},
- 'The record type is XM.ItemSite': function (error, data) {
- assert.equal(data.model.recordType, "XM.ItemSite");
+ updateHash: {
+ isSold: true
}
- }
- }).addBatch({
- 'CREATE ': crud.create(data, {
- '-> Set values': {
- topic: function (data) {
- data.model.set(data.createHash);
- return data;
- },
- 'Last Error is null': function (data) {
- assert.isNull(data.model.lastError);
- },
- '-> Save': crud.save(data)
- }
- })
- }).addBatch({
- 'READ': {
- topic: function () {
- return data;
- },
- 'ID is a number': function (data) {
- assert.isNumber(data.model.id);
- }
- }
- }).addBatch({
- 'UPDATE ': crud.update(data, {
- '-> Set values': {
- topic: function (data) {
- data.model.set(data.updateHash);
- return data;
- },
- '-> Commit': crud.save(data)
- }
- })
- }).addBatch({
- 'DESTROY': crud.destroy(data)
+ };
+
+ vows.describe('XM.ItemSite tests').addBatch({
+ 'We can run the XM.ItemSite CRUD tests ': crud.runAllCrud(data)
}).addBatch({
+ // Business-logic specific tests to be run outside of crud
'We can create a new collection and run a non-filtered fetch': {
topic: function () {
var that = this,
Oops, something went wrong.

0 comments on commit fc0f6fe

Please sign in to comment.