Skip to content

Commit

Permalink
Merge pull request #14025 from trentmwillis/should-render
Browse files Browse the repository at this point in the history
[BUGFIX] Pass environment options forward to Engines
  • Loading branch information
rwjblue authored Aug 5, 2016
2 parents 7d0c664 + d2d6e27 commit eecc9f9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/ember-application/lib/system/engine-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ if (isEnabled('ember-application-engines')) {
[
'router:main',
P`-bucket-cache:main`,
'-view-registry:main'
'-view-registry:main',
'-environment:main'
].forEach(key => this.register(key, parent.lookup(key), { instantiate: false }));

this.inject('view', '_environment', '-environment:main');
this.inject('route', '_environment', '-environment:main');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ QUnit.test('unregistering a factory clears all cached instances of that factory'

if (isEnabled('ember-application-engines')) {
QUnit.test('can build and boot a registered engine', function(assert) {
assert.expect(7);
assert.expect(8);

let ChatEngine = Engine.extend();
let chatEngineInstance;
Expand All @@ -150,6 +150,7 @@ if (isEnabled('ember-application-engines')) {

run(() => {
appInstance = ApplicationInstance.create({ application });
appInstance.setupRegistry();
chatEngineInstance = appInstance.buildChildEngineInstance('chat');
});

Expand All @@ -171,7 +172,8 @@ if (isEnabled('ember-application-engines')) {
[
'router:main',
P`-bucket-cache:main`,
'-view-registry:main'
'-view-registry:main',
'-environment:main'
].forEach(key => {
assert.strictEqual(
chatEngineInstance.lookup(key),
Expand Down
47 changes: 47 additions & 0 deletions packages/ember-application/tests/system/visit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import run from 'ember-metal/run_loop';
import RSVP, { onerrorDefault } from 'ember-runtime/ext/rsvp';
import Application from 'ember-application/system/application';
import ApplicationInstance from 'ember-application/system/application-instance';
import Engine from 'ember-application/system/engine';
import Route from 'ember-routing/system/route';
import Router from 'ember-routing/system/router';
import Component from 'ember-templates/component';
Expand Down Expand Up @@ -339,6 +340,52 @@ QUnit.test('visit() returns a promise that resolves when the view has rendered',
});
});

QUnit.test('visit() returns a promise that resolves without rendering when shouldRender is set to false', function(assert) {
assert.expect(3);

run(() => {
createApplication();

App.register('template:application', compile('<h1>Hello world</h1>'));
});

assert.strictEqual(jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element');

return run(App, 'visit', '/', { shouldRender: false }).then(instance => {
assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(jQuery('#qunit-fixture').children().length, 0, 'there are still no elements in the fixture element after visit');
});
});

QUnit.test('visit() returns a promise that resolves without rendering when shouldRender is set to false with Engines', function(assert) {
assert.expect(3);

run(() => {
createApplication();

App.register('template:application', compile('<h1>Hello world</h1>'));

// Register engine
let BlogEngine = Engine.extend();
App.register('engine:blog', BlogEngine);

// Register engine route map
let BlogMap = function() {};
App.register('route-map:blog', BlogMap);

App.Router.map(function() {
this.mount('blog');
});
});

assert.strictEqual(jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element');

return run(App, 'visit', '/blog', { shouldRender: false }).then(instance => {
assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(jQuery('#qunit-fixture').children().length, 0, 'there are still no elements in the fixture element after visit');
});
});

QUnit.module('Ember.Application - visit() Integration Tests', {
teardown() {
if (instances) {
Expand Down
1 change: 1 addition & 0 deletions packages/ember-htmlbars/tests/integration/mount_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function commonSetup() {
app.register('component-lookup:main', ComponentLookup);

appInstance = app.buildInstance();
appInstance.setupRegistry();
});
}

Expand Down

0 comments on commit eecc9f9

Please sign in to comment.