Skip to content

Commit

Permalink
fix: abort on review step (#1239)
Browse files Browse the repository at this point in the history
* fix: abort on review step

* don't unload cancelled sub and revert all the other changes

* Remove 'unloadRecord' checks in tests

* Remove commented code

---------

Co-authored-by: John Abrahams <[email protected]>
  • Loading branch information
jaredgalanis and jabrah authored Oct 25, 2023
1 parent fe08ad2 commit ff72980
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
3 changes: 2 additions & 1 deletion app/controllers/submissions/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class SubmissionsNew extends Controller {
@service submissionHandler;
@service searchHelper;
@service flashMessages;
@service router;

@tracked comment = ''; // Holds the comment that will be added to submissionEvent in the review step.
@tracked uploading = false;
Expand Down Expand Up @@ -138,7 +139,7 @@ export default class SubmissionsNew extends Controller {
// Clear the shared ignore list, then add the 'deleted' submission ID
ignoreList.clearIgnore();
ignoreList.ignore(get(submission, 'id'));
this.transitionToRoute('submissions');
this.router.transitionTo('submissions');
}
}
}
4 changes: 1 addition & 3 deletions app/services/submission-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ export default class SubmissionHandlerService extends Service {
*/
async deleteSubmission(submission) {
submission.set('submissionStatus', 'cancelled');
return submission.save().then(() => {
submission.unloadRecord();
});
return submission.save();
}
}
6 changes: 1 addition & 5 deletions tests/integration/components/submission-action-cell-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module('Integration | Component | submission action cell', (hooks) => {
* supplied submission, then `#save()` should be called
*/
test('should delete and persist submission', async function (assert) {
assert.expect(3);
assert.expect(2);

const record = EmberObject.create({
preparers: A(),
Expand All @@ -70,10 +70,6 @@ module('Integration | Component | submission action cell', (hooks) => {
assert.ok(true);
return Promise.resolve();
},
unloadRecord() {
assert.ok(true);
return Promise.resolve();
},
submitter: {
id: 1,
},
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/controllers/submissions/new-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ module('Unit | Controller | submissions/new', (hooks) => {
},
})
);
controller.set('transitionToRoute', (name) => {
assert.strictEqual(name, 'submissions', 'unexpected transition was named');
controller.set('router', {
transitionTo: (name) => {
assert.strictEqual(name, 'submissions', 'unexpected transition was named');
},
});

controller.send('abort');
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/services/submission-handler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,12 @@ module('Unit | Service | submission-handler', (hooks) => {
* objects alone
*/
test('delete submission', function (assert) {
assert.expect(4);
assert.expect(3);

const submission = EmberObject.create({
submissionStatus: 'draft',
publication: EmberObject.create({ title: 'Moo title' }),
save: () => Promise.resolve(),
unloadRecord: () => {
assert.ok(true);
return Promise.resolve();
},
});

const service = this.owner.lookup('service:submission-handler');
Expand Down

0 comments on commit ff72980

Please sign in to comment.