Skip to content

Commit b3bfcbc

Browse files
authored
Merge pull request #21 from simonihmig/prepare-fastboot-1.0
Prepare for FastBoot 1.0
2 parents e86e4fe + 022a6e7 commit b3bfcbc

23 files changed

Lines changed: 533 additions & 44 deletions

File tree

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ env:
1616
- EMBER_TRY_SCENARIO=ember-beta
1717
- EMBER_TRY_SCENARIO=ember-canary
1818
- EMBER_TRY_SCENARIO=ember-default
19+
- EMBER_TRY_SCENARIO=fastboot
20+
- EMBER_TRY_SCENARIO=fastboot-ember-2.9
1921

2022
matrix:
2123
fast_finish: true
@@ -25,9 +27,10 @@ matrix:
2527
before_install:
2628
- npm config set spin false
2729
- export PATH=$HOME/.yarn/bin:$PATH
28-
- yarn global add phantomjs-prebuilt
30+
- yarn global add phantomjs-prebuilt bower
2931
- npm --version
3032
- yarn --version
33+
- bower --version
3134
- phantomjs --version
3235

3336
install:

app-lt-2-10/instance-initializers/browser/head.js renamed to app-lt-2-10/instance-initializers/head.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Ember from 'ember';
2-
import ENV from '../../config/environment';
2+
import ENV from '../config/environment';
33

44
export function initialize(instance) {
55
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }
@@ -17,5 +17,9 @@ export function initialize(instance) {
1717

1818
export default {
1919
name: 'head-browser',
20-
initialize: initialize
20+
initialize() {
21+
if (typeof FastBoot === 'undefined') {
22+
initialize(...arguments);
23+
}
24+
}
2125
};

app/instance-initializers/fastboot/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export function initialize(owner) {
77

88
export default {
99
name: 'head-fastboot',
10-
initialize: initialize
10+
initialize
1111
};
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Ember from 'ember';
2-
import ENV from '../../config/environment';
2+
import ENV from '../config/environment';
33

44
export function initialize(owner) {
55
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }
@@ -16,5 +16,9 @@ export function initialize(owner) {
1616

1717
export default {
1818
name: 'head-browser',
19-
initialize: initialize
19+
initialize() {
20+
if (typeof FastBoot === 'undefined') {
21+
initialize(...arguments);
22+
}
23+
}
2024
};

config/ember-try.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ module.exports = {
8686
npm: {
8787
devDependencies: {}
8888
}
89+
},
90+
{
91+
name: 'fastboot',
92+
command: 'ember fastboot:test',
93+
npm: {
94+
devDependencies: {
95+
'ember-source': null
96+
}
97+
}
98+
},
99+
{
100+
name: 'fastboot-ember-2.9',
101+
command: 'ember fastboot:test --ember-version 2.9.0',
102+
npm: {
103+
devDependencies: {
104+
'ember-source': null
105+
}
106+
}
89107
}
90108
]
91109
};

app-lt-2-10/instance-initializers/fastboot/head.js renamed to fastboot-lt-2-10/instance-initializers/fastboot/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export function initialize(instance) {
1515

1616
export default {
1717
name: 'head-fastboot',
18-
initialize: initialize
18+
initialize
1919
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const expect = require('chai').expect;
4+
const setupTest = require('ember-fastboot-addon-tests').setupTest;
5+
6+
describe('FastBoot pre 1.0', function() {
7+
setupTest('fastboot-beta', {
8+
emberCliFastbootVersion: '1.0.0-beta.18'
9+
}
10+
);
11+
12+
it('index page', function() {
13+
return this.visit('/')
14+
.then(function(res) {
15+
let $ = res.jQuery;
16+
let response = res.response;
17+
18+
expect(response.statusCode).to.equal(200);
19+
expect($('h1').text().trim()).to.equal('Hello page');
20+
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Hello page');
21+
});
22+
});
23+
24+
it('other page', function() {
25+
return this.visit('/other-page')
26+
.then(function(res) {
27+
let $ = res.jQuery;
28+
let response = res.response;
29+
30+
expect(response.statusCode).to.equal(200);
31+
expect($('h1').text().trim()).to.equal('Other page');
32+
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Other page');
33+
});
34+
});
35+
36+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
const expect = require('chai').expect;
4+
const setupTest = require('ember-fastboot-addon-tests').setupTest;
5+
6+
describe('FastBoot 1.0', function() {
7+
setupTest('fastboot', {
8+
emberCliFastbootVersion: '1.0.0-rc.1'
9+
});
10+
11+
it('index page', function() {
12+
return this.visit('/')
13+
.then(function(res) {
14+
let $ = res.jQuery;
15+
let response = res.response;
16+
17+
expect(response.statusCode).to.equal(200);
18+
expect($('h1').text().trim()).to.equal('Hello page');
19+
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Hello page');
20+
});
21+
});
22+
23+
it('other page', function() {
24+
return this.visit('/other-page')
25+
.then(function(res) {
26+
let $ = res.jQuery;
27+
let response = res.response;
28+
29+
expect(response.statusCode).to.equal(200);
30+
expect($('h1').text().trim()).to.equal('Other page');
31+
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Other page');
32+
});
33+
});
34+
35+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Ember from 'ember';
2+
import config from './config/environment';
3+
4+
const Router = Ember.Router.extend({
5+
location: config.locationType,
6+
rootURL: config.rootURL
7+
});
8+
9+
Router.map(function() {
10+
this.route('other-page');
11+
});
12+
13+
export default Router;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Ember from 'ember';
2+
3+
const { set } = Ember;
4+
5+
export default Ember.Route.extend({
6+
headData: Ember.inject.service(),
7+
afterModel() {
8+
set(this, 'headData.title', "Hello page");
9+
}
10+
});

0 commit comments

Comments
 (0)