diff --git a/app/services/dependency-resolver.js b/app/services/dependency-resolver.js index b9b25417..51dd3868 100644 --- a/app/services/dependency-resolver.js +++ b/app/services/dependency-resolver.js @@ -30,7 +30,7 @@ const CHANNEL_FILENAME_MAP = { const CHANNELS = ['release', 'beta', 'canary']; -const { computed } = Ember; +const { computed, RSVP } = Ember; export default Ember.Service.extend({ resolveDependencies: function(dependencies) { @@ -49,7 +49,7 @@ export default Ember.Service.extend({ addonPromises[name] = this.resolveAddon(name, value); }); - return Ember.RSVP.hash(addonPromises).then(hash => { + return RSVP.hash(addonPromises).then(hash => { Object.keys(addons).forEach((name) => { let addon = hash[name]; if(addon.status === 'build_success') { @@ -67,15 +67,14 @@ export default Ember.Service.extend({ console.log(`Joost will have to implement some sort of error logic here..`); } }); + return RSVP.resolve(dependencies); }); }, resolveAddon(name, value) { - return new Ember.RSVP.Promise(function(resolve) { - let url = `https://nl1fctyzr7.execute-api.us-east-1.amazonaws.com/staging/addon?addon=${name}&addon_version=${value}&ember_version=1.13.15`; - Ember.$.getJSON(url, function(data){ - resolve(data); - }); + return new RSVP.Promise(function(resolve) { + const url = `https://nl1fctyzr7.execute-api.us-east-1.amazonaws.com/staging/addon?addon=${name}&addon_version=${value}&ember_version=1.13.15`; + resolve(Ember.$.getJSON(url).then(data => RSVP.resolve(data))); }); }, diff --git a/app/services/ember-cli.js b/app/services/ember-cli.js index 965e1820..5255b79f 100644 --- a/app/services/ember-cli.js +++ b/app/services/ember-cli.js @@ -389,7 +389,7 @@ export default Ember.Service.extend({ const dependencyResolver = this.get('dependencyResolver'); dependencyResolver.resolveDependencies(twiddleJson.dependencies); if ('addons' in twiddleJson) { - dependencyResolver.resolveAddons(twiddleJson.addons, twiddleJson.dependencies).then(() => { + return dependencyResolver.resolveAddons(twiddleJson.addons, twiddleJson.dependencies).then(() => { return RSVP.resolve(twiddleJson); }).catch(() => { return RSVP.reject(); diff --git a/tests/acceptance/addons-test.js b/tests/acceptance/addons-test.js new file mode 100644 index 00000000..457bcb5d --- /dev/null +++ b/tests/acceptance/addons-test.js @@ -0,0 +1,65 @@ +import Ember from 'ember'; +import { module, test } from 'qunit'; +import startApp from 'ember-twiddle/tests/helpers/start-app'; + +module('Acceptance | addons', { + beforeEach: function() { + this.application = startApp(); + this.cachePrompt = window.prompt; + window.prompt = (text, defaultResponse) => defaultResponse; + }, + + afterEach: function() { + Ember.run(this.application, 'destroy'); + window.prompt = this.cachePrompt; + } +}); + +test('Addons work', function(assert) { + + const files = [ + { + filename: "application.template.hbs", + content: `{{#if (gt appName.length 3)}} + Welcome to {{appName}} + {{/if}}` + }, + { + filename: "application.controller.js", + content: `import Ember from "ember"; + export default Ember.Controller.extend({ + appName: 'Ember Twiddle' + });` + }, + { + filename: "twiddle.json", + content: `{ + "version": "0.7.0", + "EmberENV": { + "FEATURES": {} + }, + "options": { + "use_pods": true, + "enable-testing": false + }, + "dependencies": { + "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", + "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js", + "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.2/ember-data.js", + "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js" + }, + addons: { + "ember-truth-helpers": "1.2.0" + } + }` + } + ]; + + runGist(files); + + andThen(function() { + const outputDiv = 'div'; + + assert.equal(outputContents(outputDiv), 'Welcome to Ember Twiddle'); + }); +});