From ff72980d269a7db69fb7da28cf9f37d618794587 Mon Sep 17 00:00:00 2001 From: Jared Galanis Date: Wed, 25 Oct 2023 14:44:31 -0400 Subject: [PATCH] fix: abort on review step (#1239) * 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 --- app/controllers/submissions/new.js | 3 ++- app/services/submission-handler.js | 4 +--- tests/integration/components/submission-action-cell-test.js | 6 +----- tests/unit/controllers/submissions/new-test.js | 6 ++++-- tests/unit/services/submission-handler-test.js | 6 +----- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/app/controllers/submissions/new.js b/app/controllers/submissions/new.js index c2158399..475a466d 100644 --- a/app/controllers/submissions/new.js +++ b/app/controllers/submissions/new.js @@ -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; @@ -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'); } } } diff --git a/app/services/submission-handler.js b/app/services/submission-handler.js index 8773ef3a..05778e9a 100644 --- a/app/services/submission-handler.js +++ b/app/services/submission-handler.js @@ -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(); } } diff --git a/tests/integration/components/submission-action-cell-test.js b/tests/integration/components/submission-action-cell-test.js index 3bbb9d39..8689f1ae 100644 --- a/tests/integration/components/submission-action-cell-test.js +++ b/tests/integration/components/submission-action-cell-test.js @@ -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(), @@ -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, }, diff --git a/tests/unit/controllers/submissions/new-test.js b/tests/unit/controllers/submissions/new-test.js index 5e687174..af30f716 100644 --- a/tests/unit/controllers/submissions/new-test.js +++ b/tests/unit/controllers/submissions/new-test.js @@ -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'); diff --git a/tests/unit/services/submission-handler-test.js b/tests/unit/services/submission-handler-test.js index 2fb4d64a..a4cb7257 100644 --- a/tests/unit/services/submission-handler-test.js +++ b/tests/unit/services/submission-handler-test.js @@ -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');