Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPASS-557: Generate correct id on document deletion. #692

Merged
merged 1 commit into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"hadron-app-registry": "^4.0.0",
"hadron-auto-update-manager": "^0.0.12",
"hadron-compile-cache": "^1.0.1",
"hadron-document": "^1.0.0",
"hadron-document": "^1.1.0",
"hadron-ipc": "^0.0.7",
"hadron-module-cache": "^0.0.3",
"hadron-package-manager": "0.2.0",
Expand Down
12 changes: 11 additions & 1 deletion src/internal-packages/crud/lib/component/editable-document.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const TEST_ID = 'editable-document';
*/
const HOTSPOT = `${BASE}-hostspot`;

/**
* The delete error message.
*/
const DELETE_ERROR = new Error('Cannot delete documents that do not have an _id field.');

/**
* Component for a single editable document in a list of documents.
*/
Expand Down Expand Up @@ -161,7 +166,12 @@ class EditableDocument extends React.Component {
* @param {Object} object - The object to delete.
*/
remove: function(object) {
app.dataService.deleteOne(this.ns, { _id: object._id }, {}, this.handleResult);
const id = object.getId();
if (id) {
app.dataService.deleteOne(this.ns, { _id: id }, {}, this.handleResult);
} else {
this.handleResult(DELETE_ERROR);
}
},

/**
Expand Down
6 changes: 3 additions & 3 deletions test/compass-functional.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ describe('Compass Functional Test Suite #spectron', function() {
it('updates the documents examined', function() {
return client
.getExplainDocumentsExamined()
.should.eventually.equal('2');
.should.eventually.equal('1');
});
});
});
Expand All @@ -518,11 +518,11 @@ describe('Compass Functional Test Suite #spectron', function() {
return client
.clickDocumentsTab()
.getSamplingMessageFromDocumentsTab()
.should.eventually.equal('Query returned 2 documents.');
.should.eventually.equal('Query returned 1 document.');
});

it('updates the schema view', function() {
const expected = 'This report is based on a sample of 2 documents (100.00%).';
const expected = 'This report is based on a sample of 1 document (100.00%).';
return client
.clickSchemaTab()
.getSamplingMessageFromSchemaTab()
Expand Down