More data layer changes
- Moved ::_get() and _set() from Collection/Search into DataObject, and disabled in Item - Don't disable new items after save. We now put new objects into the DataObjects cache from save() so that changes made post-save are picked up by other code using .get(). - Added 'skipCache' save() option to avoid reloading data on new objects and adding them to the cache. (This will be used in syncing, where objects might be in another library where they're not needed right away.) Objects created with this option are instead disabled to prevent reuse. - Modified some tests to try to make sure we're reloading everything properly after a save. - Documented save() options
This commit is contained in:
parent
4792b7cd48
commit
a3f4fe181f
12 changed files with 113 additions and 145 deletions
|
@ -7,7 +7,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should load data on a regular item", function* () {
|
||||
var item = new Zotero.Item('book');
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
yield item.loadAllData();
|
||||
assert.throws(item.getNote.bind(item), 'getNote() can only be called on notes and attachments');
|
||||
})
|
||||
|
@ -15,7 +14,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should load data on an attachment item", function* () {
|
||||
var item = new Zotero.Item('attachment');
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
yield item.loadAllData();
|
||||
assert.equal(item.getNote(), '');
|
||||
})
|
||||
|
@ -23,7 +21,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should load data on a note item", function* () {
|
||||
var item = new Zotero.Item('note');
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
yield item.loadAllData();
|
||||
assert.equal(item.getNote(), '');
|
||||
})
|
||||
|
@ -52,7 +49,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should be set to false after creating item", function* () {
|
||||
var item = new Zotero.Item("book");
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
assert.isFalse(item.synced);
|
||||
item.eraseTx();
|
||||
});
|
||||
|
@ -60,7 +56,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should be set to true when changed", function* () {
|
||||
var item = new Zotero.Item("book");
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
|
||||
item.synced = 1;
|
||||
yield item.saveTx();
|
||||
|
@ -72,7 +67,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should be set to false after modifying item", function* () {
|
||||
var item = new Zotero.Item("book");
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
|
||||
item.synced = 1;
|
||||
yield item.saveTx();
|
||||
|
@ -88,7 +82,6 @@ describe("Zotero.DataObject", function() {
|
|||
it("should be unchanged if skipSyncedUpdate passed", function* () {
|
||||
var item = new Zotero.Item("book");
|
||||
var id = yield item.saveTx();
|
||||
item = yield Zotero.Items.getAsync(id);
|
||||
|
||||
item.synced = 1;
|
||||
yield item.saveTx();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue