Skip to content

Commit

Permalink
misoproject#131 - moving deferred definition outside the fetch for ea…
Browse files Browse the repository at this point in the history
…rly access.
  • Loading branch information
Irene Ros committed Jun 13, 2012
1 parent 2b0ae54 commit 2b61a95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dataset.js
Expand Up @@ -149,13 +149,14 @@ Version 0.0.1.2
// implementation, pass it as an option
if (options.deferred) {
this.deferred = options.deferred;
} else {
this.deferred = new _.Deferred();
}

//build any columns present in the constructor
if ( options.columns ) {
this.addColumns(options.columns);
}

},

/**
Expand Down Expand Up @@ -186,7 +187,7 @@ Version 0.0.1.2
fetch : function(options) {
options = options || {};

var dfd = this.deferred || new _.Deferred();
var dfd = this.deferred;

if ( _.isNull(this.importer) ) {
throw "No importer defined";
Expand Down
21 changes: 21 additions & 0 deletions test/unit/bugs.js
Expand Up @@ -5,6 +5,27 @@

module("Bugs");

test("#131 - Deferred object should be accessible before fetch", 1, function() {
var key = "0Asnl0xYK7V16dFpFVmZUUy1taXdFbUJGdGtVdFBXbFE",
worksheet = "1";

var ds = new Miso.Dataset({
importer: Miso.Importers.GoogleSpreadsheet,
parser : Miso.Parsers.GoogleSpreadsheet,
key : key,
worksheet: worksheet
});

stop();

_.when(ds.deferred).then(function() {
ok(true);
start();
});

ds.fetch();
});

test("#133 - Google spreadsheet column duplicate name check (Regular)",1, function() {
var ds = new Miso.Dataset({
parser: Miso.Parsers.GoogleSpreadsheet,
Expand Down

0 comments on commit 2b61a95

Please sign in to comment.