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

Officejs: do not redefine existing variable

parent 4ed1cec5
......@@ -79,13 +79,13 @@
function equalStorage(storage, doc_tuple_list) {
return storage.allDocs()
.push(function (result) {
var i,
var j,
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([
result.data.rows[i].id,
storage.get(result.data.rows[i].id),
storage.getAttachment(result.data.rows[i].id, ATTACHMENT)
result.data.rows[j].id,
storage.get(result.data.rows[j].id),
storage.getAttachment(result.data.rows[j].id, ATTACHMENT)
]));
}
return RSVP.all(promise_list);
......@@ -182,14 +182,14 @@
expect(2);
stop();
var test = this;
var that = this;
this.jio.repair()
.then(function () {
return RSVP.all([
isEmptyStorage(test.jio),
isEmptyStorage(that.jio),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1}
)
]);
......@@ -206,24 +206,24 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(test.jio, [[doc_id, doc, blob]]),
equalStorage(that.jio, [[doc_id, doc, blob]]),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1}
)
]);
......@@ -243,21 +243,21 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(test.jio, [[doc_id, doc, blob]]),
equalStorage(that.jio, [[doc_id, doc, blob]]),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1, get: 1, getAttachment: 1, allAttachments: 1}
)
]);
......@@ -277,7 +277,7 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
......@@ -286,10 +286,10 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.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);
})
.then(function () {
......@@ -320,27 +320,27 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
test.remote_mock_options.mock.buildQuery = function () {
that.remote_mock_options.mock.buildQuery = function () {
return [];
};
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
isEmptyStorage(test.jio),
isEmptyStorage(that.jio),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1}
)
]);
......@@ -360,24 +360,24 @@
expect(3);
stop();
var test = this,
var that = this,
doc_id = 'abc',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio, doc_id, doc, blob)
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(
test.jio,
[[test.remote_mock_options.last_post_id, doc, blob]]
that.jio,
[[that.remote_mock_options.last_post_id, doc, blob]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1, post: 1, putAttachment: 1, allAttachments: 1}
)
]);
......@@ -403,7 +403,7 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
......@@ -413,24 +413,24 @@
putFullDoc(this.jio, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
last_id = test.remote_mock_options.last_post_id;
return putFullDoc(test.jio, last_id, doc2, blob2);
last_id = that.remote_mock_options.last_post_id;
return putFullDoc(that.jio, last_id, doc2, blob2);
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(
test.jio.__storage._remote_sub_storage,
that.jio.__storage._remote_sub_storage,
[[last_id, doc2, blob2]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1, put: 1,
allAttachments: 1, putAttachment: 1}
)
......@@ -451,7 +451,7 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
......@@ -462,27 +462,27 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return RSVP.all([
putFullDoc(test.jio.__storage._remote_sub_storage, doc_id,
putFullDoc(that.jio.__storage._remote_sub_storage, doc_id,
doc2, blob2),
putFullDoc(test.jio, doc_id, doc3, blob3)
putFullDoc(that.jio, doc_id, doc3, blob3)
]);
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(
test.jio.__storage._remote_sub_storage,
that.jio.__storage._remote_sub_storage,
[[doc_id, doc3, blob3]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1, put: 1,
allAttachments: 1, putAttachment: 1}
)
......@@ -500,7 +500,7 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
......@@ -509,19 +509,19 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return putFullDoc(test.jio, doc_id, doc2, blob2);
return putFullDoc(that.jio, doc_id, doc2, blob2);
})
.then(function () {
test.remote_mock_options.mock.put = function () {
that.remote_mock_options.mock.put = function () {
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');
};
resetCount(test.remote_mock_options.count);
resetCount(that.remote_mock_options.count);
return test.jio.repair();
})
.then(function () {
......@@ -542,31 +542,31 @@
expect(3);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return test.jio.remove(doc_id);
return that.jio.remove(doc_id);
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return RSVP.all([
isEmptyStorage(test.jio),
isEmptyStorage(that.jio),
equalStorage(
test.jio.__storage._remote_sub_storage,
that.jio.__storage._remote_sub_storage,
[[doc_id, doc, blob]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1}
)
]);
......@@ -583,30 +583,30 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
blob = new Blob(['a']);
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return test.jio.removeAttachment(doc_id, ATTACHMENT);
return that.jio.removeAttachment(doc_id, ATTACHMENT);
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(
test.jio.__storage._remote_sub_storage,
that.jio.__storage._remote_sub_storage,
[[doc_id, doc, blob]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1}
)
]);
......@@ -623,7 +623,7 @@
expect(2);
stop();
var test = this,
var that = this,
doc_id = 'foo_module/1',
doc = {title: doc_id, portal_type: "Foo", modification_date: 'a'},
doc2 = {title: doc_id + 'a', portal_type: "Foo", modification_date: 'b'},
......@@ -632,31 +632,31 @@
putFullDoc(this.jio.__storage._remote_sub_storage, doc_id, doc, blob)
.then(function () {
return test.jio.repair();
return that.jio.repair();
})
.then(function () {
return RSVP.all([
putFullDoc(test.jio.__storage._remote_sub_storage, doc_id,
putFullDoc(that.jio.__storage._remote_sub_storage, doc_id,
doc2, blob2),
test.jio.remove(doc_id)
that.jio.remove(doc_id)
]);
})
.then(function () {
resetCount(test.remote_mock_options.count);
return test.jio.repair();
resetCount(that.remote_mock_options.count);
return that.jio.repair();
})
.then(function () {
return RSVP.all([
equalStorage(
test.jio,
that.jio,
[[doc_id, doc2, blob2]]
),
equalStorage(
test.jio.__storage._remote_sub_storage,
that.jio.__storage._remote_sub_storage,
[[doc_id, doc2, blob2]]
),
equalRemoteStorageCallCount(
test.remote_mock_options.count,
that.remote_mock_options.count,
{buildQuery: 1, get: 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