Skip to content

Commit

Permalink
Do not register a router service for Ember <1.13
Browse files Browse the repository at this point in the history
Versions of Ember prior to 1.13 require a full router booted by the app,
or no router at all. This ensures they receive no router at all instead
of the 1.13-safe one.
  • Loading branch information
mixonic committed Sep 9, 2015
1 parent 5f148ff commit 34e13b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/ember-test-helpers/test-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { Klass } from 'klassy';
import { getResolver } from './test-resolver';
import buildRegistry from './build-registry';

function hasEmberVersion(major, minor) {
var numbers = Ember.VERSION.split('-')[0].split('.');
var actualMajor = parseInt(numbers[0], 10);
var actualMinor = parseInt(numbers[1], 10);
return actualMajor > major || (actualMajor === major && actualMinor >= minor);
}

export default Klass.extend({
init: function(subjectName, description, callbacks) {
// Allow `description` to be omitted, in which case it should
Expand Down Expand Up @@ -234,10 +241,12 @@ export default Klass.extend({
this.container = items.container;
this.registry = items.registry;

var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
router = router || Ember.Router.extend();
thingToRegisterWith.register('router:main', router);
if (hasEmberVersion(1, 13)) {
var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
router = router || Ember.Router.extend();
thingToRegisterWith.register('router:main', router);
}
},

_setupIsolatedContainer: function() {
Expand Down
5 changes: 5 additions & 0 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ test('it can render a template', function() {
equal(this.$('span').text(), 'Hello');
});

test('it can render a link-to', function() {
this.render("{{link-to 'Hi' 'index'}}");
ok(true, 'it renders without fail');
});

test('it complains if you try to use bare render', function() {
var self = this;
throws(function() {
Expand Down

0 comments on commit 34e13b9

Please sign in to comment.