From f21731b771d031b817a687fd4ecb8516dfa478b9 Mon Sep 17 00:00:00 2001 From: Leonard Smith Date: Wed, 7 Oct 2020 13:41:57 -0500 Subject: [PATCH] Add a cunstom-inflector to handle pluralizing entry --- app/initializers/custom-inflector-rules.js | 13 +++++++++ .../custom-inflector-rules-test.js | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/initializers/custom-inflector-rules.js create mode 100644 tests/unit/initializers/custom-inflector-rules-test.js diff --git a/app/initializers/custom-inflector-rules.js b/app/initializers/custom-inflector-rules.js new file mode 100644 index 0000000..9604737 --- /dev/null +++ b/app/initializers/custom-inflector-rules.js @@ -0,0 +1,13 @@ +import Inflector from 'ember-inflector'; + +export function initialize(/* application */) { + const inflector = Inflector.inflector; + + // Tell the inflector that the plural of "entry" is "entries" + inflector.irregular('entry', 'entries'); +} + +export default { + name: 'custom-inflector-rules', + initialize +}; diff --git a/tests/unit/initializers/custom-inflector-rules-test.js b/tests/unit/initializers/custom-inflector-rules-test.js new file mode 100644 index 0000000..bf6a2d9 --- /dev/null +++ b/tests/unit/initializers/custom-inflector-rules-test.js @@ -0,0 +1,29 @@ +import Application from '@ember/application'; + +import { initialize } from 'gwt-frontend/initializers/custom-inflector-rules'; +import { module, test } from 'qunit'; +import Resolver from 'ember-resolver'; +import { run } from '@ember/runloop'; + +module('Unit | Initializer | custom-inflector-rules', function(hooks) { + hooks.beforeEach(function() { + this.TestApplication = class TestApplication extends Application {} + this.TestApplication.initializer({ + name: 'initializer under test', + initialize + }); + + this.application = this.TestApplication.create({ autoboot: false, Resolver }); + }); + + hooks.afterEach(function() { + run(this.application, 'destroy'); + }); + + // TODO: Replace this with your real tests. + test('it works', async function(assert) { + await this.application.boot(); + + assert.ok(true); + }); +});