Skip to content

Fix flaky Parse.GeoPoint test. #908

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

Merged
merged 2 commits into from
Mar 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 27 additions & 31 deletions spec/ParseGeoPoint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,33 @@ describe('Parse.GeoPoint testing', () => {
});
});

//
// This test is disabled, since it's extremely flaky on Travis-CI.
// Tracking issue: https://github.com/ParsePlatform/parse-server/issues/572
//
// it('geo line', (done) => {
// var line = [];
// for (var i = 0; i < 10; ++i) {
// var obj = new TestObject();
// var point = new Parse.GeoPoint(i * 4.0 - 12.0, i * 3.2 - 11.0);
// obj.set('location', point);
// obj.set('construct', 'line');
// obj.set('seq', i);
// line.push(obj);
// }
// Parse.Object.saveAll(line, {
// success: function() {
// var query = new Parse.Query(TestObject);
// var point = new Parse.GeoPoint(24, 19);
// query.equalTo('construct', 'line');
// query.withinMiles('location', point, 10000);
// query.find({
// success: function(results) {
// equal(results.length, 10);
// equal(results[0].get('seq'), 9);
// equal(results[3].get('seq'), 6);
// done();
// }
// });
// }
// });
// });
it('geo line', (done) => {
var line = [];
for (var i = 0; i < 10; ++i) {
var obj = new TestObject();
var point = new Parse.GeoPoint(i * 4.0 - 12.0, i * 3.2 - 11.0);
obj.set('location', point);
obj.set('construct', 'line');
obj.set('seq', i);
line.push(obj);
}
Parse.Object.saveAll(line, {
success: function() {
var query = new Parse.Query(TestObject);
var point = new Parse.GeoPoint(24, 19);
query.equalTo('construct', 'line');
query.withinMiles('location', point, 10000);
query.find({
success: function(results) {
equal(results.length, 10);
equal(results[0].get('seq'), 9);
equal(results[3].get('seq'), 6);
done();
}
});
}
});
});

it('geo max distance large', (done) => {
var objects = [];
Expand Down
9 changes: 6 additions & 3 deletions src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,12 @@ class Schema {
geocount++;
}
if (geocount > 1) {
throw new Parse.Error(
Parse.Error.INCORRECT_TYPE,
'there can only be one geopoint field in a class');
// Make sure all field validation operations run before we return.
// If not - we are continuing to run logic, but already provided response from the server.
return promise.then(() => {
return Promise.reject(new Parse.Error(Parse.Error.INCORRECT_TYPE,
'there can only be one geopoint field in a class'));
});
}
if (!expected) {
continue;
Expand Down