diff --git a/addon/ext/route.js b/addon/ext/route.js index 94732892..83d7c914 100644 --- a/addon/ext/route.js +++ b/addon/ext/route.js @@ -1,7 +1,7 @@ import Mixin from '@ember/object/mixin'; export default Mixin.create({ - activate() { + setupController() { this.get('perfService').routeActivated(this); this._super(...arguments); }, diff --git a/tests/acceptance/event-body-test.js b/tests/acceptance/event-body-test.js index 6c90f390..2e7e6e2e 100644 --- a/tests/acceptance/event-body-test.js +++ b/tests/acceptance/event-body-test.js @@ -136,6 +136,44 @@ test('Initial load, then drilling in, then pivoting', function(assert) { }); }); +test('Nested resource with the same name ', function(assert) { + // This test covers the bug here: https://github.com/mike-north/ember-perf/issues/83 + + let datas = []; + let testStartTime = performanceNow(); + + application.perfService.on('transitionComplete', (data) => { + datas.push(data); + }); + + visit('/articles/1'); + + andThen(function() { + assert.ok(datas, 'Data is present'); + let [data] = datas; + validateEvent(assert, testStartTime, data); + assert.equal(datas.length, 1, 'Only one event fired'); + }); + + click('a[href=\'/articles/2\']'); + + andThen(function() { + assert.equal(datas.length, 2, 'Only two events fired'); + let data = datas[datas.length - 1]; + assert.equal(data.destURL, '/articles/2', 'Intent URL is correct'); + assert.equal(data.destRoute, 'articles.article', 'Intent route is correct'); + }); + + click('a[href=\'/articles/3\']'); + + andThen(function() { + assert.equal(datas.length, 3, 'Only three events fired'); + let data = datas[datas.length - 1]; + assert.equal(data.destURL, '/articles/3', 'Intent URL is correct'); + assert.equal(data.destRoute, 'articles.article', 'Intent route is correct'); + }); +}); + test('Initial measureRender', function(assert) { let datas = []; let testStartTime = performanceNow(); diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index f464422f..6f7a2c88 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -7,6 +7,9 @@ const Router = EmberRouter.extend({ }); Router.map(function() { + this.route('articles', function() { + this.route('article', { path: ':article_id' }); + }); this.route('companies', function() { this.route('info'); }); diff --git a/tests/dummy/app/routes/articles/article.js b/tests/dummy/app/routes/articles/article.js new file mode 100644 index 00000000..af611ce2 --- /dev/null +++ b/tests/dummy/app/routes/articles/article.js @@ -0,0 +1,4 @@ +// import Ember from 'ember'; +import BaseRoute from '../base'; + +export default BaseRoute.extend({ }); diff --git a/tests/dummy/app/routes/base.js b/tests/dummy/app/routes/base.js index 10e904a0..b5c8585b 100644 --- a/tests/dummy/app/routes/base.js +++ b/tests/dummy/app/routes/base.js @@ -1,5 +1,8 @@ +import Object from '@ember/object'; import Route from '@ember/routing/route'; export default Route.extend({ - -}); \ No newline at end of file + model(params) { + return Object.create({id: params.article_id}); + } +}); diff --git a/tests/dummy/app/templates/articles/article.hbs b/tests/dummy/app/templates/articles/article.hbs new file mode 100644 index 00000000..9ebdd072 --- /dev/null +++ b/tests/dummy/app/templates/articles/article.hbs @@ -0,0 +1,9 @@ +