Skip to content

Commit 909c141

Browse files
Merge pull request #840 from ember-fastboot/suchita/metadefault
Add a default state for metadata
2 parents 589faf6 + b009505 commit 909c141

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

packages/fastboot/src/ember-app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class EmberApp {
301301
let bootOptions = buildBootOptions(shouldRender);
302302
let fastbootInfo = new FastBootInfo(req, res, {
303303
hostWhitelist: this.hostWhitelist,
304-
metadata: options.metadata,
304+
metadata: options.metadata || {},
305305
});
306306

307307
let doc = bootOptions.document;

test-packages/basic-app/app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ Router.map(function() {
1515
this.route('async-content');
1616
this.route('echo-request-headers');
1717
this.route('return-status-code-418');
18+
this.route('metadata');
1819
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default Route.extend({
5+
fastboot: service(),
6+
7+
model() {
8+
if (this.get('fastboot.isFastBoot') && this.fastboot.metadata) {
9+
return 'test fastboot metadata';
10+
}
11+
},
12+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{this.model}}

test-packages/integration-tests/test/basic-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,20 @@ describe("FastBoot", function() {
186186
.then((r) => r.html());
187187
expect(html).to.match(/foo from sandbox: 5/);
188188
});
189+
190+
it("does not break the render with empty metadata", async function() {
191+
const fastboot = new FastBoot({
192+
distPath: await buildDist("basic-app"),
193+
});
194+
195+
return fastboot
196+
.visit("/metadata", {
197+
request: dummyRequest(),
198+
response: dummyResponse(),
199+
})
200+
.then((r) => r.html())
201+
.then((html) => {
202+
expect(html).to.match(/test fastboot metadata/);
203+
});
204+
});
189205
});

0 commit comments

Comments
 (0)