From f53878d078f4854e8f1c3ce93a4fa317634daa16 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Mon, 15 Feb 2016 09:55:08 -0500 Subject: [PATCH 1/9] upgrade to ember 2.3, cli-2.3, fixed loading route being used --- addon/components/bread-crumbs.js | 7 ++++--- bower.json | 7 ++----- ember-cli-build.js | 7 ++++--- package.json | 8 +++++--- testem.json | 3 ++- tests/dummy/app/app.js | 5 +++-- tests/dummy/app/index.html | 8 ++++---- tests/helpers/resolver.js | 2 +- tests/helpers/start-app.js | 8 +++----- tests/index.html | 19 ++++++++++--------- 10 files changed, 38 insertions(+), 36 deletions(-) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index fda2959..dc8ed62 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -74,9 +74,9 @@ export default Component.extend({ }, _lookupRoute(routeName) { - const container = get(this, 'container'); + const container = Ember.getOwner(this); const route = container.lookup(`route:${routeName}`); - assert(`[ember-crumbly] \`route:${routeName}\` was not found`, route); + // assert(`[ember-crumbly] \`route:${routeName}\` was not found`, route); return route; }, @@ -86,7 +86,8 @@ export default Component.extend({ const pathLength = routeNames.length; const breadCrumbs = filteredRouteNames.map((name, index) => { const path = this._guessRoutePath(routeNames, name, index); - let breadCrumb = this._lookupRoute(path).getWithDefault('breadCrumb', undefined); + let route = this._lookupRoute(path); + let breadCrumb = route && route.getWithDefault('breadCrumb', undefined); const breadCrumbType = typeOf(breadCrumb); if (index === pathLength - 1) { diff --git a/bower.json b/bower.json index b99715d..b5d4ab8 100644 --- a/bower.json +++ b/bower.json @@ -1,15 +1,12 @@ { "name": "ember-crumbly", "dependencies": { - "ember": "1.13.7", - "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3", + "ember": "2.3.0", + "ember-cli-shims": "0.1.0", "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", - "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5", "ember-qunit": "0.4.9", "ember-qunit-notifications": "0.0.7", - "ember-resolver": "~0.1.18", "jquery": "^1.11.3", - "loader.js": "ember-cli/loader.js#3.2.1", "qunit": "~1.18.0" } } diff --git a/ember-cli-build.js b/ember-cli-build.js index d37d64c..4ac3913 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -1,13 +1,14 @@ +/*jshint node:true*/ /* global require, module */ -var EmberApp = require('ember-cli/lib/broccoli/ember-addon'); +var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); module.exports = function(defaults) { - var app = new EmberApp(defaults, { + var app = new EmberAddon(defaults, { // Add options here }); /* - This build file specifes the options for the dummy test app of this + This build file specifies the options for the dummy test app of this addon, located in `/tests/dummy` This build file does *not* influence how the addon or the app using it behave. You most likely want to be modifying `./index.js` or app's build file diff --git a/package.json b/package.json index 38c86a2..4732e24 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,14 @@ "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.1.2", - "ember-cli": "1.13.8", + "ember-cli": "^2.3.0-beta.2", "ember-cli-app-version": "0.5.0", "ember-cli-content-security-policy": "0.4.0", "ember-cli-dependency-checker": "^1.0.1", "ember-cli-htmlbars-inline-precompile": "^0.2.0", "ember-cli-ic-ajax": "0.2.1", "ember-cli-inject-live-reload": "^1.3.1", + "ember-load-initializers": "^0.5.0", "ember-cli-qunit": "^1.0.0", "ember-cli-release": "0.2.3", "ember-cli-sri": "^1.0.3", @@ -33,8 +34,9 @@ "ember-disable-prototype-extensions": "^1.0.0", "ember-disable-proxy-controllers": "^1.0.0", "ember-export-application-global": "^1.0.3", - "ember-suave": "1.0.0", - "ember-try": "0.0.6" + "ember-resolver": "2.0.3", + "ember-try": "0.0.6", + "loader.js": "ember-cli/loader.js#v4.0.0" }, "keywords": [ "ember-addon", diff --git a/testem.json b/testem.json index 5de2d54..0f35392 100644 --- a/testem.json +++ b/testem.json @@ -6,6 +6,7 @@ "PhantomJS" ], "launch_in_dev": [ - "PhantomJS" + "PhantomJS", + "Chrome" ] } diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js index 6b56916..831ad61 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -import Resolver from 'ember/resolver'; -import loadInitializers from 'ember/load-initializers'; +import Resolver from './resolver'; +import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; let App; @@ -9,6 +9,7 @@ Ember.MODEL_FACTORY_INJECTIONS = true; App = Ember.Application.extend({ modulePrefix: config.modulePrefix, + podModulePrefix: config.podModulePrefix, Resolver }); diff --git a/tests/dummy/app/index.html b/tests/dummy/app/index.html index 1c49d36..c9b4327 100644 --- a/tests/dummy/app/index.html +++ b/tests/dummy/app/index.html @@ -7,19 +7,19 @@ - {{content-for 'head'}} + {{content-for "head"}} - {{content-for 'head-footer'}} + {{content-for "head-footer"}} - {{content-for 'body'}} + {{content-for "body"}} - {{content-for 'body-footer'}} + {{content-for "body-footer"}} diff --git a/tests/helpers/resolver.js b/tests/helpers/resolver.js index ebfb4e4..ac94b1b 100644 --- a/tests/helpers/resolver.js +++ b/tests/helpers/resolver.js @@ -1,4 +1,4 @@ -import Resolver from 'ember/resolver'; +import Resolver from 'ember-resolver'; import config from '../../config/environment'; const resolver = Resolver.create(); diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index df9eab3..e098f1d 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -2,15 +2,13 @@ import Ember from 'ember'; import Application from '../../app'; import config from '../../config/environment'; -const { run, merge } = Ember; - export default function startApp(attrs) { let application; - let attributes = merge({}, config.APP); - attributes = merge(attributes, attrs); // use defaults, but you can override; + let attributes = Ember.merge({}, config.APP); + attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; - run(() => { + Ember.run(() => { application = Application.create(attributes); application.setupForTesting(); application.injectTestHelpers(); diff --git a/tests/index.html b/tests/index.html index 8fea6fe..64cb47e 100644 --- a/tests/index.html +++ b/tests/index.html @@ -7,27 +7,28 @@ - {{content-for 'head'}} - {{content-for 'test-head'}} + {{content-for "head"}} + {{content-for "test-head"}} - {{content-for 'head-footer'}} - {{content-for 'test-head-footer'}} + {{content-for "head-footer"}} + {{content-for "test-head-footer"}} + {{content-for "body"}} + {{content-for "test-body"}} - {{content-for 'body'}} - {{content-for 'test-body'}} + - + - {{content-for 'body-footer'}} - {{content-for 'test-body-footer'}} + {{content-for "body-footer"}} + {{content-for "test-body-footer"}} From a330602b51624297cea1f31e137bbacd15631d13 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Mon, 15 Feb 2016 10:17:50 -0500 Subject: [PATCH 2/9] touch up to exclud loading/error --- addon/components/bread-crumbs.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index dc8ed62..35fbc0f 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -76,6 +76,9 @@ export default Component.extend({ _lookupRoute(routeName) { const container = Ember.getOwner(this); const route = container.lookup(`route:${routeName}`); + if (routeName.match(/loading|error/)) { + return null; + } // assert(`[ember-crumbly] \`route:${routeName}\` was not found`, route); return route; From f70971874224165a049e1991700846a00860f4d9 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 10:46:32 -0400 Subject: [PATCH 3/9] refactors --- addon/components/bread-crumbs.js | 122 +++++++++++---------------- bower.json | 9 +- package.json | 34 ++++---- tests/acceptance/integration-test.js | 32 ++----- 4 files changed, 75 insertions(+), 122 deletions(-) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index 35fbc0f..bd2c432 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -1,21 +1,22 @@ import Ember from 'ember'; import layout from '../templates/components/bread-crumbs'; import computed from 'ember-new-computed'; +import getOwner from 'ember-getowner-polyfill'; const { - get, - Component, - getWithDefault, - assert, - typeOf, - setProperties, - A: emberArray, - String: { classify } -} = Ember; + get, + Component, + getWithDefault, + assert, + setProperties, + A: emberArray, + String: { classify }, + inject + } = Ember; const { - bool, - readOnly -} = computed; + bool, + readOnly + } = computed; export default Component.extend({ layout, @@ -24,96 +25,69 @@ export default Component.extend({ reverse: false, classNameBindings: ['breadCrumbClass'], hasBlock: bool('template').readOnly(), - currentUrl: readOnly('applicationRoute.router.url'), - currentRouteName: readOnly('applicationRoute.controller.currentRouteName'), + routing: inject.service('-routing'), + currentUrl: readOnly('routing.router.url'), + currentRouteName: readOnly('routing.currentRouteName'), - routeHierarchy: computed('currentUrl', 'currentRouteName', 'reverse', { - get() { - const currentRouteName = getWithDefault(this, 'currentRouteName', false); + routeHierarchy: computed('currentUrl', 'reverse', function() { + const currentRouteName = get(this, 'currentRouteName'); + assert('[ember-crumbly] Could not find a curent route', currentRouteName); - assert('[ember-crumbly] Could not find a curent route', currentRouteName); + const routeNames = currentRouteName.split('.'); + const filteredRouteNames = this._filterIndexAndLoadingRoutes(routeNames); + const crumbs = this._lookupBreadCrumb(routeNames, filteredRouteNames); - const routeNames = this._splitCurrentRouteName(currentRouteName); - const filteredRouteNames = this._filterIndexRoutes(routeNames); - - const crumbs = this._lookupBreadCrumb(routeNames, filteredRouteNames); - return this.get('reverse') ? crumbs.reverse() : crumbs; - } + return get(this, 'reverse') ? crumbs.reverse() : crumbs; }).readOnly(), - breadCrumbClass: computed('outputStyle', { - get() { - let className = 'breadcrumb'; - const outputStyle = getWithDefault(this, 'outputStyle', ''); - const lowerCaseOutputStyle = outputStyle.toLowerCase(); - - if (lowerCaseOutputStyle === 'foundation') { - className = 'breadcrumbs'; - } - - return className; - } + breadCrumbClass: computed('outputStyle', function() { + const outputStyle = getWithDefault(this, 'outputStyle', ''); + return (outputStyle.match(/foundation/i)) ? 'breadcrumbs' : 'breadcrumb'; }).readOnly(), - _splitCurrentRouteName(currentRouteName) { - return currentRouteName.split('.'); - }, - _guessRoutePath(routeNames, name, index) { const routes = routeNames.slice(0, index + 1); if (routes.length === 1) { - return `${name}.index`; + let path = `${name}.index`; + + return (this._lookupRoute(path)) ? path : name; } return routes.join('.'); }, - _filterIndexRoutes(routeNames) { - return routeNames.filter((name) => name !== 'index'); + _filterIndexAndLoadingRoutes(routeNames) { + return routeNames.filter((name) => !(name.match(/^(index|loading)$/))); }, _lookupRoute(routeName) { - const container = Ember.getOwner(this); - const route = container.lookup(`route:${routeName}`); - if (routeName.match(/loading|error/)) { - return null; - } - // assert(`[ember-crumbly] \`route:${routeName}\` was not found`, route); - - return route; + return getOwner(this).lookup(`route:${routeName}`); }, _lookupBreadCrumb(routeNames, filteredRouteNames) { - let defaultLinkable = get(this, 'linkable'); + const defaultLinkable = get(this, 'linkable'); const pathLength = routeNames.length; - const breadCrumbs = filteredRouteNames.map((name, index) => { + + return emberArray(filteredRouteNames.map((name, index) => { const path = this._guessRoutePath(routeNames, name, index); - let route = this._lookupRoute(path); - let breadCrumb = route && route.getWithDefault('breadCrumb', undefined); - const breadCrumbType = typeOf(breadCrumb); + const route = this._lookupRoute(path); - if (index === pathLength - 1) { - defaultLinkable = false; - } - if (breadCrumbType === 'undefined') { - breadCrumb = { - path, - linkable: defaultLinkable, - title: classify(name) - }; - } else if (breadCrumbType === 'null') { - return; - } else { + assert(`[ember-crumbly] \`route:${path}\` was not found`, route); + + let breadCrumb = getWithDefault(route, 'breadCrumb', { + title: classify(name) + }); + + if (breadCrumb) { + const crumbLinkable = (index === pathLength - 1) ? false : defaultLinkable; setProperties(breadCrumb, { path, - linkable: breadCrumb.hasOwnProperty('linkable') ? breadCrumb.linkable : defaultLinkable + linkable: breadCrumb.hasOwnProperty('linkable') ? breadCrumb.linkable : crumbLinkable }); + return breadCrumb; } - return breadCrumb; - }); - - return emberArray(breadCrumbs.filter((breadCrumb) => typeOf(breadCrumb) !== 'undefined')); + })).compact(); } -}); +}); \ No newline at end of file diff --git a/bower.json b/bower.json index b5d4ab8..4e1871a 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,9 @@ { "name": "ember-crumbly", "dependencies": { - "ember": "2.3.0", + "ember": "~2.3.1", "ember-cli-shims": "0.1.0", - "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", - "ember-qunit": "0.4.9", - "ember-qunit-notifications": "0.0.7", - "jquery": "^1.11.3", - "qunit": "~1.18.0" + "ember-cli-test-loader": "0.2.2", + "ember-qunit-notifications": "0.1.0" } } diff --git a/package.json b/package.json index 4732e24..4afe2dc 100644 --- a/package.json +++ b/package.json @@ -19,24 +19,23 @@ "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.1.2", - "ember-cli": "^2.3.0-beta.2", - "ember-cli-app-version": "0.5.0", - "ember-cli-content-security-policy": "0.4.0", - "ember-cli-dependency-checker": "^1.0.1", - "ember-cli-htmlbars-inline-precompile": "^0.2.0", - "ember-cli-ic-ajax": "0.2.1", + "ember-cli": "^2.3.0", + "ember-cli-app-version": "^1.0.0", + "ember-cli-dependency-checker": "^1.2.0", + "ember-cli-htmlbars-inline-precompile": "^0.3.1", + "ember-ajax": "0.7.1", "ember-cli-inject-live-reload": "^1.3.1", "ember-load-initializers": "^0.5.0", - "ember-cli-qunit": "^1.0.0", - "ember-cli-release": "0.2.3", - "ember-cli-sri": "^1.0.3", + "ember-cli-qunit": "^1.2.1", + "ember-cli-release": "0.2.8", + "ember-cli-sri": "^2.0.0", "ember-cli-uglify": "^1.2.0", - "ember-disable-prototype-extensions": "^1.0.0", - "ember-disable-proxy-controllers": "^1.0.0", - "ember-export-application-global": "^1.0.3", + "ember-disable-prototype-extensions": "^1.1.0", + "ember-disable-proxy-controllers": "^1.0.1", + "ember-export-application-global": "^1.0.4", "ember-resolver": "2.0.3", - "ember-try": "0.0.6", - "loader.js": "ember-cli/loader.js#v4.0.0" + "ember-try": "0.1.2", + "loader.js": "^4.0.0" }, "keywords": [ "ember-addon", @@ -46,9 +45,10 @@ "crumbly" ], "dependencies": { - "ember-cli-babel": "^5.1.3", - "ember-cli-htmlbars": "0.7.9", - "ember-new-computed": "^1.0.3" + "ember-cli-babel": "^5.1.5", + "ember-cli-htmlbars": "^1.0.1", + "ember-new-computed": "^1.0.3", + "ember-getowner-polyfill": "^1.0.0" }, "ember-addon": { "configPath": "tests/dummy/config", diff --git a/tests/acceptance/integration-test.js b/tests/acceptance/integration-test.js index b4efed3..db5e896 100644 --- a/tests/acceptance/integration-test.js +++ b/tests/acceptance/integration-test.js @@ -1,33 +1,15 @@ import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; -import { - lookupComponent -} from '../helpers/lookup'; - -const { run } = Ember; - -let application; -let componentInstance; - -module('Acceptance | ember-crumbly integration test', { - beforeEach() { - application = startApp(); - componentInstance = lookupComponent(application, 'bread-crumbs'); - }, - - afterEach() { - componentInstance = null; - run(application, 'destroy'); - } -}); +import { test } from 'qunit'; +import moduleForAcceptance from '../helpers/module-for-acceptance'; + +moduleForAcceptance('Acceptance | ember-crumbly integration test'); test('routeHierarchy returns the correct number of routes', function(assert) { assert.expect(3); visit('/foo/bar/baz'); andThen(() => { - const routeHierarchy = componentInstance.get('routeHierarchy'); + const routeHierarchy = this.componentInstance.get('routeHierarchy'); const numberOfRenderedBreadCrumbs = find('#bootstrapLinkable li').length; assert.equal(currentRouteName(), 'foo.bar.baz.index', 'correct current route name'); assert.equal(routeHierarchy.length, 3, 'returns correct number of routes'); @@ -40,7 +22,7 @@ test('routes that opt-out are not shown', function(assert) { visit('/foo/bar/baz/hidden'); andThen(() => { - const routeHierarchy = componentInstance.get('routeHierarchy'); + const routeHierarchy = this.componentInstance.get('routeHierarchy'); const numberOfRenderedBreadCrumbs = find('#foundationLinkable li').length; assert.equal(currentRouteName(), 'foo.bar.baz.hidden', 'correct current route name'); assert.equal(routeHierarchy.length, 3, 'returns correct number of routes'); @@ -53,7 +35,7 @@ test('routes can set dynamic breadcrumb props', function(assert) { visit('/foo/bar/baz/show'); andThen(() => { - const routeHierarchy = componentInstance.get('routeHierarchy'); + const routeHierarchy = this.componentInstance.get('routeHierarchy'); const routeTitles = routeHierarchy.map((route) => route.title); const routeLooks = routeHierarchy.map((route) => route.look); const routeLinkables = routeHierarchy.map((route) => route.linkable); From ffdde7b802373975143c21c4853e01bb6915dc41 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 10:46:46 -0400 Subject: [PATCH 4/9] test adds --- tests/dummy/app/resolver.js | 3 +++ tests/helpers/destroy-app.js | 5 +++++ tests/helpers/module-for-acceptance.js | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/dummy/app/resolver.js create mode 100644 tests/helpers/destroy-app.js create mode 100644 tests/helpers/module-for-acceptance.js diff --git a/tests/dummy/app/resolver.js b/tests/dummy/app/resolver.js new file mode 100644 index 0000000..2fb563d --- /dev/null +++ b/tests/dummy/app/resolver.js @@ -0,0 +1,3 @@ +import Resolver from 'ember-resolver'; + +export default Resolver; diff --git a/tests/helpers/destroy-app.js b/tests/helpers/destroy-app.js new file mode 100644 index 0000000..c3d4d1a --- /dev/null +++ b/tests/helpers/destroy-app.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default function destroyApp(application) { + Ember.run(application, 'destroy'); +} diff --git a/tests/helpers/module-for-acceptance.js b/tests/helpers/module-for-acceptance.js new file mode 100644 index 0000000..cdfe7b3 --- /dev/null +++ b/tests/helpers/module-for-acceptance.js @@ -0,0 +1,24 @@ +import {module} from 'qunit'; +import startApp from '../helpers/start-app'; +import destroyApp from '../helpers/destroy-app'; +import {lookupComponent} from '../helpers/lookup'; + +export default function(name, options = {}) { + module(name, { + beforeEach() { + this.application = startApp(); + this.componentInstance = lookupComponent(this.application, 'bread-crumbs'); + if (options.beforeEach) { + options.beforeEach.apply(this, arguments); + } + }, + + afterEach() { + destroyApp(this.application); + this.componentInstance = null; + if (options.afterEach) { + options.afterEach.apply(this, arguments); + } + } + }); +} From 979dd59fe9987f3b7cbd19aaaa4e49d9ad804b96 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 16:20:16 -0400 Subject: [PATCH 5/9] fixed for ember 1.11/1.12 --- addon/components/bread-crumbs.js | 17 +++++++++-------- bower.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index bd2c432..59a7649 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -9,9 +9,7 @@ const { getWithDefault, assert, setProperties, - A: emberArray, - String: { classify }, - inject + String: { classify } } = Ember; const { bool, @@ -25,19 +23,22 @@ export default Component.extend({ reverse: false, classNameBindings: ['breadCrumbClass'], hasBlock: bool('template').readOnly(), - routing: inject.service('-routing'), - currentUrl: readOnly('routing.router.url'), - currentRouteName: readOnly('routing.currentRouteName'), +// router: Ember.inject.service('-routing'), +// currentUrl: readOnly('router.router.url'), +// currentRouteName: readOnly('router.currentRouteName'), + currentUrl: readOnly('applicationRoute.router.url'), + currentRouteName: readOnly('applicationRoute.controller.currentRouteName'), routeHierarchy: computed('currentUrl', 'reverse', function() { const currentRouteName = get(this, 'currentRouteName'); + assert('[ember-crumbly] Could not find a curent route', currentRouteName); const routeNames = currentRouteName.split('.'); const filteredRouteNames = this._filterIndexAndLoadingRoutes(routeNames); const crumbs = this._lookupBreadCrumb(routeNames, filteredRouteNames); - return get(this, 'reverse') ? crumbs.reverse() : crumbs; + return get(this, 'reverse') ? Ember.A(crumbs.reverse()) : Ember.A(crumbs); }).readOnly(), breadCrumbClass: computed('outputStyle', function() { @@ -69,7 +70,7 @@ export default Component.extend({ const defaultLinkable = get(this, 'linkable'); const pathLength = routeNames.length; - return emberArray(filteredRouteNames.map((name, index) => { + return Ember.A(filteredRouteNames.map((name, index) => { const path = this._guessRoutePath(routeNames, name, index); const route = this._lookupRoute(path); diff --git a/bower.json b/bower.json index 4e1871a..fc15b2f 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "ember-crumbly", "dependencies": { - "ember": "~2.3.1", + "ember": "1.12", "ember-cli-shims": "0.1.0", "ember-cli-test-loader": "0.2.2", "ember-qunit-notifications": "0.1.0" From 8223e361a27ff9c9c61f44450086e45b100b71c0 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 16:21:52 -0400 Subject: [PATCH 6/9] ember back to 2.3 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index fc15b2f..4e1871a 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "ember-crumbly", "dependencies": { - "ember": "1.12", + "ember": "~2.3.1", "ember-cli-shims": "0.1.0", "ember-cli-test-loader": "0.2.2", "ember-qunit-notifications": "0.1.0" From b903cc95511251dd1c050df1a2c2380c5b650cda Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 16:24:08 -0400 Subject: [PATCH 7/9] added comment for 2.0 --- addon/components/bread-crumbs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index 59a7649..ee9e735 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -23,6 +23,7 @@ export default Component.extend({ reverse: false, classNameBindings: ['breadCrumbClass'], hasBlock: bool('template').readOnly(), + // for Ember 2.0+ // router: Ember.inject.service('-routing'), // currentUrl: readOnly('router.router.url'), // currentRouteName: readOnly('router.currentRouteName'), From 3de4700d2c81bf3871a68522058ecfa7e0876994 Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Sat, 4 Jun 2016 22:00:29 -0400 Subject: [PATCH 8/9] fluff --- addon/components/bread-crumbs.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index ee9e735..82d9dd7 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -4,17 +4,18 @@ import computed from 'ember-new-computed'; import getOwner from 'ember-getowner-polyfill'; const { - get, - Component, - getWithDefault, - assert, - setProperties, - String: { classify } - } = Ember; + get, + Component, + getWithDefault, + assert, + setProperties, + String: { classify } +} = Ember; + const { - bool, - readOnly - } = computed; + bool, + readOnly +} = computed; export default Component.extend({ layout, @@ -24,9 +25,9 @@ export default Component.extend({ classNameBindings: ['breadCrumbClass'], hasBlock: bool('template').readOnly(), // for Ember 2.0+ -// router: Ember.inject.service('-routing'), -// currentUrl: readOnly('router.router.url'), -// currentRouteName: readOnly('router.currentRouteName'), + // router: Ember.inject.service('-routing'), + // currentUrl: readOnly('router.router.url'), + // currentRouteName: readOnly('router.currentRouteName'), currentUrl: readOnly('applicationRoute.router.url'), currentRouteName: readOnly('applicationRoute.controller.currentRouteName'), From 630b7362cf00601d9e4366b1b71b06ed1a72d59f Mon Sep 17 00:00:00 2001 From: Dan Sudol Date: Mon, 6 Jun 2016 20:06:26 -0400 Subject: [PATCH 9/9] more like master tests --- tests/acceptance/integration-test.js | 18 ++++++++++++++---- tests/helpers/module-for-acceptance.js | 3 +-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/integration-test.js b/tests/acceptance/integration-test.js index db5e896..8bee977 100644 --- a/tests/acceptance/integration-test.js +++ b/tests/acceptance/integration-test.js @@ -1,15 +1,25 @@ import Ember from 'ember'; import { test } from 'qunit'; import moduleForAcceptance from '../helpers/module-for-acceptance'; +import {lookupComponent} from '../helpers/lookup'; -moduleForAcceptance('Acceptance | ember-crumbly integration test'); +let componentInstance; +moduleForAcceptance('Acceptance | ember-crumbly integration test', { + beforeEach() { + componentInstance = lookupComponent(this.application, 'bread-crumbs'); + }, + + afterEach() { + componentInstance = null; + } +}); test('routeHierarchy returns the correct number of routes', function(assert) { assert.expect(3); visit('/foo/bar/baz'); andThen(() => { - const routeHierarchy = this.componentInstance.get('routeHierarchy'); + const routeHierarchy = componentInstance.get('routeHierarchy'); const numberOfRenderedBreadCrumbs = find('#bootstrapLinkable li').length; assert.equal(currentRouteName(), 'foo.bar.baz.index', 'correct current route name'); assert.equal(routeHierarchy.length, 3, 'returns correct number of routes'); @@ -22,7 +32,7 @@ test('routes that opt-out are not shown', function(assert) { visit('/foo/bar/baz/hidden'); andThen(() => { - const routeHierarchy = this.componentInstance.get('routeHierarchy'); + const routeHierarchy = componentInstance.get('routeHierarchy'); const numberOfRenderedBreadCrumbs = find('#foundationLinkable li').length; assert.equal(currentRouteName(), 'foo.bar.baz.hidden', 'correct current route name'); assert.equal(routeHierarchy.length, 3, 'returns correct number of routes'); @@ -35,7 +45,7 @@ test('routes can set dynamic breadcrumb props', function(assert) { visit('/foo/bar/baz/show'); andThen(() => { - const routeHierarchy = this.componentInstance.get('routeHierarchy'); + const routeHierarchy = componentInstance.get('routeHierarchy'); const routeTitles = routeHierarchy.map((route) => route.title); const routeLooks = routeHierarchy.map((route) => route.look); const routeLinkables = routeHierarchy.map((route) => route.linkable); diff --git a/tests/helpers/module-for-acceptance.js b/tests/helpers/module-for-acceptance.js index cdfe7b3..39c73ed 100644 --- a/tests/helpers/module-for-acceptance.js +++ b/tests/helpers/module-for-acceptance.js @@ -1,13 +1,12 @@ import {module} from 'qunit'; import startApp from '../helpers/start-app'; import destroyApp from '../helpers/destroy-app'; -import {lookupComponent} from '../helpers/lookup'; export default function(name, options = {}) { module(name, { beforeEach() { this.application = startApp(); - this.componentInstance = lookupComponent(this.application, 'bread-crumbs'); + if (options.beforeEach) { options.beforeEach.apply(this, arguments); }