Default to user library for saved searches
For consistency with collections and items
This commit is contained in:
parent
574f636683
commit
18714a4fcb
|
@ -134,9 +134,6 @@ Zotero.Search.prototype.loadFromRow = function (row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Search.prototype._initSave = Zotero.Promise.coroutine(function* (env) {
|
Zotero.Search.prototype._initSave = Zotero.Promise.coroutine(function* (env) {
|
||||||
if (!this.libraryID) {
|
|
||||||
throw new Error('libraryID must be set before saving search');
|
|
||||||
}
|
|
||||||
if (!this.name) {
|
if (!this.name) {
|
||||||
throw new Error('Name not provided for saved search');
|
throw new Error('Name not provided for saved search');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
describe("Zotero.Search", function() {
|
describe("Zotero.Search", function() {
|
||||||
describe("#save()", function () {
|
describe("#save()", function () {
|
||||||
it("should fail without a libraryID", function* () {
|
|
||||||
var s = new Zotero.Search;
|
|
||||||
s.name = "Test";
|
|
||||||
s.addCondition('title', 'is', 'test');
|
|
||||||
var e = yield getPromiseError(s.save());
|
|
||||||
assert.ok(e);
|
|
||||||
assert.equal(e.constructor.name, Error.prototype.constructor.name); // TEMP: Error mismatch
|
|
||||||
assert.equal(e.message, "libraryID must be set before saving search");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should fail without a name", function* () {
|
it("should fail without a name", function* () {
|
||||||
var s = new Zotero.Search;
|
var s = new Zotero.Search;
|
||||||
s.libraryID = Zotero.Libraries.userLibraryID;
|
|
||||||
s.addCondition('title', 'is', 'test');
|
s.addCondition('title', 'is', 'test');
|
||||||
var e = yield getPromiseError(s.save());
|
var e = yield getPromiseError(s.save());
|
||||||
assert.ok(e);
|
assert.ok(e);
|
||||||
|
@ -23,7 +12,6 @@ describe("Zotero.Search", function() {
|
||||||
it("should save a new search", function* () {
|
it("should save a new search", function* () {
|
||||||
// Save search
|
// Save search
|
||||||
var s = new Zotero.Search;
|
var s = new Zotero.Search;
|
||||||
s.libraryID = Zotero.Libraries.userLibraryID;
|
|
||||||
s.name = "Test";
|
s.name = "Test";
|
||||||
s.addCondition('title', 'is', 'test');
|
s.addCondition('title', 'is', 'test');
|
||||||
var id = yield s.save();
|
var id = yield s.save();
|
||||||
|
@ -33,6 +21,7 @@ describe("Zotero.Search", function() {
|
||||||
s = yield Zotero.Searches.getAsync(id);
|
s = yield Zotero.Searches.getAsync(id);
|
||||||
assert.ok(s);
|
assert.ok(s);
|
||||||
assert.instanceOf(s, Zotero.Search);
|
assert.instanceOf(s, Zotero.Search);
|
||||||
|
assert.equal(s.libraryID, Zotero.Libraries.userLibraryID);
|
||||||
assert.equal(s.name, "Test");
|
assert.equal(s.name, "Test");
|
||||||
yield s.loadConditions();
|
yield s.loadConditions();
|
||||||
var conditions = s.getConditions();
|
var conditions = s.getConditions();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user