Commit 21458ee6 authored by Romain Courteaud's avatar Romain Courteaud

Officejs: do not redefine existing variable

parent 4ed1cec5
...@@ -79,13 +79,13 @@ ...@@ -79,13 +79,13 @@
function equalStorage(storage, doc_tuple_list) { function equalStorage(storage, doc_tuple_list) {
return storage.allDocs() return storage.allDocs()
.push(function (result) { .push(function (result) {
var i, var j,
promise_list = []; promise_list = [];
for (i = 0; i < result.data.rows.length; i += 1) { for (j = 0; j < result.data.rows.length; j += 1) {
promise_list.push(RSVP.all([ promise_list.push(RSVP.all([
result.data.rows[i].id, result.data.rows[j].id,
storage.get(result.data.rows[i].id), storage.get(result.data.rows[j].id),
storage.getAttachment(result.data.rows[i].id, ATTACHMENT) storage.getAttachment(result.data.rows[j].id, ATTACHMENT)
])); ]));
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
...@@ -182,14 +182,14 @@ ...@@ -182,14 +182,14 @@
expect(2); expect(2);
stop(); stop();
var test = this; var that = this;
this.jio.repair() this.jio.repair()
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
isEmptyStorage(test.jio), isEmptyStorage(that.jio),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1} {buildQuery: 1}
) )
]); ]);
...@@ -206,24 +206,24 @@ ...@@ -206,24 +206,24 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(test.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage(test.jio, [[doc_id, doc, blob]]), equalStorage(that.jio, [[doc_id, doc, blob]]),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1} {buildQuery: 1}
) )
]); ]);
...@@ -243,21 +243,21 @@ ...@@ -243,21 +243,21 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage(test.jio, [[doc_id, doc, blob]]), equalStorage(that.jio, [[doc_id, doc, blob]]),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1, get: 1, getAttachment: 1, allAttachments: 1} {buildQuery: 1, get: 1, getAttachment: 1, allAttachments: 1}
) )
]); ]);
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'}, doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
...@@ -286,10 +286,10 @@ ...@@ -286,10 +286,10 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return putFullDoc(test.jio.__storage._remote_sub_storage, doc_id, doc2, return putFullDoc(that.jio.__storage._remote_sub_storage, doc_id, doc2,
blob2); blob2);
}) })
.then(function () { .then(function () {
...@@ -320,27 +320,27 @@ ...@@ -320,27 +320,27 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
test.remote_mock_options.mock.buildQuery = function () { that.remote_mock_options.mock.buildQuery = function () {
return []; return [];
}; };
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
isEmptyStorage(test.jio), isEmptyStorage(that.jio),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1} {buildQuery: 1}
) )
]); ]);
...@@ -360,24 +360,24 @@ ...@@ -360,24 +360,24 @@
expect(3); expect(3);
stop(); stop();
var test = this, var that = this,
doc_id = 'abc', doc_id = 'abc',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio, doc_id, doc, blob) putFullDoc(this.jio, doc_id, doc, blob)
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage( equalStorage(
test.jio, that.jio,
[[test.remote_mock_options.last_post_id, doc, blob]] [[that.remote_mock_options.last_post_id, doc, blob]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1, post: 1, putAttachment: 1, allAttachments: 1} {buildQuery: 1, post: 1, putAttachment: 1, allAttachments: 1}
) )
]); ]);
...@@ -403,7 +403,7 @@ ...@@ -403,7 +403,7 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'}, doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
...@@ -413,24 +413,24 @@ ...@@ -413,24 +413,24 @@
putFullDoc(this.jio, doc_id, doc, blob) putFullDoc(this.jio, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
last_id = test.remote_mock_options.last_post_id; last_id = that.remote_mock_options.last_post_id;
return putFullDoc(test.jio, last_id, doc2, blob2); return putFullDoc(that.jio, last_id, doc2, blob2);
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage( equalStorage(
test.jio.__storage._remote_sub_storage, that.jio.__storage._remote_sub_storage,
[[last_id, doc2, blob2]] [[last_id, doc2, blob2]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1, put: 1, {buildQuery: 1, put: 1,
allAttachments: 1, putAttachment: 1} allAttachments: 1, putAttachment: 1}
) )
...@@ -451,7 +451,7 @@ ...@@ -451,7 +451,7 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'}, doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
...@@ -462,27 +462,27 @@ ...@@ -462,27 +462,27 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
putFullDoc(test.jio.__storage._remote_sub_storage, doc_id, putFullDoc(that.jio.__storage._remote_sub_storage, doc_id,
doc2, blob2), doc2, blob2),
putFullDoc(test.jio, doc_id, doc3, blob3) putFullDoc(that.jio, doc_id, doc3, blob3)
]); ]);
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage( equalStorage(
test.jio.__storage._remote_sub_storage, that.jio.__storage._remote_sub_storage,
[[doc_id, doc3, blob3]] [[doc_id, doc3, blob3]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1, put: 1, {buildQuery: 1, put: 1,
allAttachments: 1, putAttachment: 1} allAttachments: 1, putAttachment: 1}
) )
...@@ -500,7 +500,7 @@ ...@@ -500,7 +500,7 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'}, doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
...@@ -509,19 +509,19 @@ ...@@ -509,19 +509,19 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return putFullDoc(test.jio, doc_id, doc2, blob2); return putFullDoc(that.jio, doc_id, doc2, blob2);
}) })
.then(function () { .then(function () {
test.remote_mock_options.mock.put = function () { that.remote_mock_options.mock.put = function () {
throw new Error('put not allowed'); throw new Error('put not allowed');
}; };
test.remote_mock_options.mock.putAttachment = function () { that.remote_mock_options.mock.putAttachment = function () {
throw new Error('putattachment not allowed'); throw new Error('putattachment not allowed');
}; };
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return test.jio.repair();
}) })
.then(function () { .then(function () {
...@@ -542,31 +542,31 @@ ...@@ -542,31 +542,31 @@
expect(3); expect(3);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return test.jio.remove(doc_id); return that.jio.remove(doc_id);
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(test.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
isEmptyStorage(test.jio), isEmptyStorage(that.jio),
equalStorage( equalStorage(
test.jio.__storage._remote_sub_storage, that.jio.__storage._remote_sub_storage,
[[doc_id, doc, blob]] [[doc_id, doc, blob]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1} {buildQuery: 1}
) )
]); ]);
...@@ -583,30 +583,30 @@ ...@@ -583,30 +583,30 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']); blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return test.jio.removeAttachment(doc_id, ATTACHMENT); return that.jio.removeAttachment(doc_id, ATTACHMENT);
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(test.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage( equalStorage(
test.jio.__storage._remote_sub_storage, that.jio.__storage._remote_sub_storage,
[[doc_id, doc, blob]] [[doc_id, doc, blob]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1} {buildQuery: 1}
) )
]); ]);
...@@ -623,7 +623,7 @@ ...@@ -623,7 +623,7 @@
expect(2); expect(2);
stop(); stop();
var test = this, var that = this,
doc_id = 'foo_module/1', doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'}, doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'}, doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
...@@ -632,31 +632,31 @@ ...@@ -632,31 +632,31 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob) putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () { .then(function () {
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
putFullDoc(test.jio.__storage._remote_sub_storage, doc_id, putFullDoc(that.jio.__storage._remote_sub_storage, doc_id,
doc2, blob2), doc2, blob2),
test.jio.remove(doc_id) that.jio.remove(doc_id)
]); ]);
}) })
.then(function () { .then(function () {
resetCount(test.remote_mock_options.count); resetCount(that.remote_mock_options.count);
return test.jio.repair(); return that.jio.repair();
}) })
.then(function () { .then(function () {
return RSVP.all([ return RSVP.all([
equalStorage( equalStorage(
test.jio, that.jio,
[[doc_id, doc2, blob2]] [[doc_id, doc2, blob2]]
), ),
equalStorage( equalStorage(
test.jio.__storage._remote_sub_storage, that.jio.__storage._remote_sub_storage,
[[doc_id, doc2, blob2]] [[doc_id, doc2, blob2]]
), ),
equalRemoteStorageCallCount( equalRemoteStorageCallCount(
test.remote_mock_options.count, that.remote_mock_options.count,
{buildQuery: 1, get: 1, {buildQuery: 1, get: 1,
allAttachments: 1, getAttachment: 1} allAttachments: 1, getAttachment: 1}
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment