Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/services/ember-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ export default Em.Service.extend({

this.addBoilerPlateFiles(out, gist);

let twiddleJson = this.getTwiddleJson(gist);

// Add boot code
contentForAppBoot(out, {modulePrefix: twiddleAppName});
contentForAppBoot(out, {modulePrefix: twiddleAppName, dependencies: twiddleJson.dependencies});

resolve(Ember.Object.create({
code: out.join('\n'),
styles: cssOut.join('\n'),
twiddleJson: this.getTwiddleJson(gist)
twiddleJson: twiddleJson
}));
});

Expand Down Expand Up @@ -270,11 +272,14 @@ function contentForAppBoot (content, config) {
// doesn't recognize them properly...
var monkeyPatchModules = [
'ember',
'ember-data',
'ember/resolver',
'ember/load-initializers'
];

if ("ember-data" in config.dependencies) {
monkeyPatchModules.push('ember-data');
}

monkeyPatchModules.forEach(function(mod) {
content.push(' require("'+mod+'").__esModule=true;');
});
Expand Down
49 changes: 49 additions & 0 deletions tests/acceptance/dependency-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

module('Acceptance | external dependency', {
beforeEach: function() {
this.application = startApp();
},

afterEach: function() {
Ember.run(this.application, 'destroy');
}
});

test('Able to run a gist using an external dependency', function(assert) {

const files = [
{
filename: "application.template.hbs",
content: "{{version}}"
},
{
filename: "application.controller.js",
content: "import Ember from 'ember';\n\nexport default Ember.Controller.extend({\n version: _.VERSION\n});\n"
},
{
filename: 'twiddle.json',
content:
'{\n' +
' "version": "0.4.0",\n' +
' "dependencies": {\n' +
' "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",\n' +
' "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js",\n' +
' "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember-template-compiler.js",\n' +
' "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.7/ember-data.js",\n' +
' "lodash": "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.js"\n' +
' }\n' +
'}'
}
];

runGist(files);

andThen(function() {
const outputDiv = 'div';

assert.equal(outputContents(outputDiv), '3.10.0', 'Gist including an external dependency can make use of it');
});
});
13 changes: 6 additions & 7 deletions tests/acceptance/gist-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

let application;
let cacheConfirm;

const firstFilePicker = '.code:first-of-type .dropdown-toggle';
const secondFile = '.code:first-of-type .dropdown-menu li:nth-child(2) a';
const anyFile = '.code:first-of-type .dropdown-menu li:nth-child(1) a';
Expand All @@ -18,15 +15,17 @@ let promptValue = '';

module('Acceptance | gist', {
beforeEach: function() {
application = startApp();
cacheConfirm = window.confirm;
this.application = startApp();
this.cacheConfirm = window.confirm;
this.cachePrompt = window.prompt;
window.confirm = () => true;
window.prompt = () => promptValue;
},

afterEach: function() {
Ember.run(application, 'destroy');
window.confirm = cacheConfirm;
Ember.run(this.application, 'destroy');
window.confirm = this.cacheConfirm;
window.prompt = this.cachePrompt;
}
});

Expand Down
6 changes: 2 additions & 4 deletions tests/acceptance/minimal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

let application;

module('Acceptance | minimal', {
beforeEach: function() {
application = startApp();
this.application = startApp();
},

afterEach: function() {
Ember.run(application, 'destroy');
Ember.run(this.application, 'destroy');
}
});

Expand Down
35 changes: 35 additions & 0 deletions tests/acceptance/no-compiler-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

module('Acceptance | no template compiler', {
beforeEach: function() {
this.application = startApp();
},

afterEach: function() {
Ember.run(this.application, 'destroy');
}
});

test('Able to load a gist without a template compiler', function(assert) {

const files = [
{
filename: "application.template.hbs",
content: "Hello, World!"
},
{
filename: 'twiddle.json',
content: "{\n \"version\": \"0.4.0\",\n \"dependencies\": {\n \"jquery\": \"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js\",\n \"ember\": \"https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js\"\n }\n}"
}
];

runGist(files);

andThen(function() {
const outputDiv = 'div';

assert.equal(outputContents(outputDiv), 'Hello, World!', 'Gist with no template compiler is displayed');
});
});
6 changes: 2 additions & 4 deletions tests/acceptance/routing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

let application;

module('Acceptance | routing', {
beforeEach: function() {
application = startApp();
this.application = startApp();
},

afterEach: function() {
Ember.run(application, 'destroy');
Ember.run(this.application, 'destroy');
}
});

Expand Down
44 changes: 44 additions & 0 deletions tests/acceptance/version-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

module('Acceptance | older version', {
beforeEach: function() {
this.application = startApp();
},

afterEach: function() {
Ember.run(this.application, 'destroy');
}
});

test('Able to run a gist using an older version of Ember', function(assert) {

const files = [
{
filename: "application.template.hbs",
content: "Hello, World!"
},
{
filename: 'twiddle.json',
content:
'{\n' +
' "version": "0.4.0",\n' +
' "dependencies": {\n' +
' "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",\n' +
' "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.12.1/ember.js",\n' +
' "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.12.1/ember-template-compiler.js",\n' +
' "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.0.0-beta.14.1/ember-data.js"\n' +
' }\n' +
'}'
}
];

runGist(files);

andThen(function() {
const outputDiv = 'div';

assert.equal(outputContents(outputDiv), 'Hello, World!', 'Gist running Ember 1.12.1 is displayed');
});
});