Skip to content

Commit aa20fe1

Browse files
committed
keyword: Rethrow non-404 errors
1 parent 5c3547d commit aa20fe1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

app/routes/keyword.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export default Route.extend({
1212
this.flashMessages.queue(`Keyword '${keyword_id}' does not exist`);
1313
return this.replaceWith('index');
1414
}
15+
16+
throw e;
1517
}
1618
},
1719
});

tests/routes/keyword-test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { currentURL } from '@ember/test-helpers';
2+
import { setupApplicationTest } from 'ember-qunit';
3+
import { module, test } from 'qunit';
4+
5+
import setupMirage from '../helpers/setup-mirage';
6+
import { visit } from '../helpers/visit-ignoring-abort';
7+
8+
module('Route | keyword', function (hooks) {
9+
setupApplicationTest(hooks);
10+
setupMirage(hooks);
11+
12+
test("shows an error message if the keyword can't be found", async function (assert) {
13+
await visit('/keywords/unknown');
14+
assert.equal(currentURL(), '/');
15+
assert.dom('[data-test-flash-message]').hasText("Keyword 'unknown' does not exist");
16+
});
17+
18+
test('server error causes the error page to be shown', async function (assert) {
19+
this.server.get('/api/v1/keywords/:keywordId', {}, 500);
20+
21+
await visit('/keywords/error');
22+
assert.equal(currentURL(), '/keywords/error');
23+
assert.dom('[data-test-error-message]').includesText('GET /api/v1/keywords/error returned a 500');
24+
});
25+
});

0 commit comments

Comments
 (0)