Skip to content

Commit

Permalink
fixes #701: don't start transaction for POST submission.csv (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiqkhoja authored Jul 3, 2023
1 parent 5415280 commit 891edc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/http/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Problem = require('../util/problem');

// determines if a request needs a transaction.
const phony = (request) => {
if (/submissions\.csv\.zip$/i.test(request.path)) return true;
if (/submissions\.csv(\.zip)?$/i.test(request.path)) return true;
return false;
};
const isWriteRequest = (request) => !phony(request) &&
Expand Down
26 changes: 13 additions & 13 deletions test/unit/http/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,20 +361,20 @@ describe('endpoints', () => {
.then(() => { transacted.should.equal(false); });
})));

it('should not initiate a transaction given a nonwrite POST', () => {
let transacted = false;
const container = {
transacting(cb) { transacted = true; return cb(); },
with() { return container; }
};
it('should not initiate a transaction given a nonwrite POST', () =>
Promise.all([
'/projects/1/forms/encrypted/submissions.csv',
'/projects/1/forms/encrypted/submissions.csv.zip'
].map((path) => {
let transacted = false;
const container = {
transacting(cb) { transacted = true; return cb(); },
with() { return container; }
};

const request = {
method: 'POST',
path: '/projects/1/forms/encrypted/submissions.csv.zip'
};
return endpointBase({ resultWriter: noop })(container)(always(true))(request)
.then(() => { transacted.should.equal(false); });
});
return endpointBase({ resultWriter: noop })(container)(always(true))({ method: 'POST', path })
.then(() => { transacted.should.equal(false); });
})));

it('should reject on the transacting promise on preprocessor failure', () => {
// we still check the transacted flag just to be sure the rejectedWith assertion runs.
Expand Down

0 comments on commit 891edc2

Please sign in to comment.