Skip to content
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
51 changes: 43 additions & 8 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ describe('Cloud Code', () => {
done();
});
});

it('beforeSave change propagates through the afterSave #1931', (done) => {
Parse.Cloud.beforeSave('ChangingObject', function(request, response) {
request.object.unset('file');
Expand Down Expand Up @@ -1044,7 +1044,7 @@ describe('Cloud Code', () => {
res.success();
});
}).not.toThrow();

rp.post({
url: 'http://localhost:8378/1/jobs/myJob',
headers: {
Expand All @@ -1065,7 +1065,7 @@ describe('Cloud Code', () => {
res.success();
});
}).not.toThrow();

rp.post({
url: 'http://localhost:8378/1/jobs/myJob',
headers: {
Expand Down Expand Up @@ -1094,7 +1094,7 @@ describe('Cloud Code', () => {
done();
});
}).not.toThrow();

rp.post({
url: 'http://localhost:8378/1/jobs/myJob',
headers: {
Expand All @@ -1121,7 +1121,7 @@ describe('Cloud Code', () => {
done();
});
}).not.toThrow();

rp.post({
url: `http://${Parse.applicationId}:${Parse.masterKey}@localhost:8378/1/jobs/myJob`,
}).then(() => {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ describe('Cloud Code', () => {
done();
});
});

rp.post({
url: 'http://localhost:8378/1/jobs/myJob',
headers: {
Expand All @@ -1179,7 +1179,7 @@ describe('Cloud Code', () => {
done();
});
});

rp.post({
url: 'http://localhost:8378/1/jobs/myJob',
headers: {
Expand Down Expand Up @@ -1434,5 +1434,40 @@ describe('afterFind hooks', () => {
});
});

});
it('should alter select', (done) => {
Parse.Cloud.beforeFind('MyObject', (req) => {
req.query.select('white');
return req.query;
});

const obj0 = new Parse.Object('MyObject')
.set('white', true)
.set('black', true);
obj0.save()
.then(() => {
new Parse.Query('MyObject')
.first()
.then(result => {
expect(result.get('white')).toBe(true);
expect(result.get('black')).toBe(undefined);
done();
});
});
});

it('should not alter select', (done) => {
const obj0 = new Parse.Object('MyObject')
.set('white', true)
.set('black', true);
obj0.save()
.then(() => {
new Parse.Query('MyObject')
.first()
.then(result => {
expect(result.get('white')).toBe(true);
expect(result.get('black')).toBe(true);
done();
});
});
});
});
4 changes: 4 additions & 0 deletions src/triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ export function maybeRunQueryTrigger(triggerType, className, restWhere, restOpti
restOptions = restOptions || {};
restOptions.include = jsonQuery.include;
}
if (jsonQuery.keys) {
restOptions = restOptions || {};
restOptions.keys = jsonQuery.keys;
}
return {
restWhere,
restOptions
Expand Down