diff --git a/app/assets/javascripts/discourse/controllers/notification.js.es6 b/app/assets/javascripts/discourse/controllers/notification.js.es6 index 2fa73d44726..12b3734121a 100644 --- a/app/assets/javascripts/discourse/controllers/notification.js.es6 +++ b/app/assets/javascripts/discourse/controllers/notification.js.es6 @@ -31,12 +31,12 @@ export default ObjectController.extend({ if (this.get('notification_type') === INVITED_TYPE) { return '/my/invited'; } - }.property("data.{badge_id, badge_name}", "slug", "topic_id", "post_number"), + }.property("data.{badge_id,badge_name}", "slug", "topic_id", "post_number"), description: function () { var badgeName = this.safe("data.badge_name"); if (badgeName) { return badgeName; } return this.blank("data.topic_title") ? "" : this.safe("data.topic_title"); - }.property("data.{badge_name, topic_title}") + }.property("data.{badge_name,topic_title}") }); diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js index 53127ad824d..77d001be512 100644 --- a/app/assets/javascripts/discourse/models/composer.js +++ b/app/assets/javascripts/discourse/models/composer.js @@ -473,16 +473,16 @@ Discourse.Composer = Discourse.Model.extend({ }); this.set('composeState', CLOSED); - return Em.Deferred.promise(function(promise) { + return new Ember.RSVP.Promise(function(resolve, reject) { post.save(function(result) { post.updateFromPost(result); composer.clearState(); }, function(error) { var response = $.parseJSON(error.responseText); if (response && response.errors) { - promise.reject(response.errors[0]); + reject(response.errors[0]); } else { - promise.reject(I18n.t('generic_error')); + reject(I18n.t('generic_error')); } post.set('cooked', oldCooked); composer.set('composeState', OPEN); @@ -550,7 +550,7 @@ Discourse.Composer = Discourse.Model.extend({ } var composer = this; - return Em.Deferred.promise(function(promise) { + return new Ember.RSVP.Promise(function(resolve, reject) { composer.set('composeState', SAVING); createdPost.save(function(result) { @@ -584,7 +584,7 @@ Discourse.Composer = Discourse.Model.extend({ composer.set('composeState', SAVING); } - return promise.resolve({ post: result }); + return resolve({ post: result }); }, function(error) { // If an error occurs if (postStream) { @@ -605,7 +605,7 @@ Discourse.Composer = Discourse.Model.extend({ catch(ex) { parsedError = "Unknown error saving post, try again. Error: " + error.status + " " + error.statusText; } - promise.reject(parsedError); + reject(parsedError); }); }); }, diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index 9f318133334..a3716d62956 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -15,6 +15,10 @@ function response(code, obj) { return [code, {"Content-Type": "application/json"}, obj]; } +function success() { + return response(); +} + export default function() { var server = new Pretender(function() { @@ -77,6 +81,9 @@ export default function() { this.get('/login.html', function() { return [200, {}, 'LOGIN PAGE']; }); + + this.delete('/posts/:post_id', success); + this.put('/posts/:post_id/recover', success); }); diff --git a/test/javascripts/models/composer-test.js.es6 b/test/javascripts/models/composer-test.js.es6 index cd2e431ce24..afcb156cd2a 100644 --- a/test/javascripts/models/composer-test.js.es6 +++ b/test/javascripts/models/composer-test.js.es6 @@ -158,8 +158,8 @@ test('editingFirstPost', function() { asyncTestDiscourse('importQuote with a post', function() { expect(1); - sandbox.stub(Discourse.Post, 'load').withArgs(123).returns(Em.Deferred.promise(function (p) { - p.resolve(Discourse.Post.create({raw: "let's quote"})); + sandbox.stub(Discourse.Post, 'load').withArgs(123).returns(new Ember.RSVP.Promise(function (resolve) { + resolve(Discourse.Post.create({raw: "let's quote"})); })); var composer = Discourse.Composer.create({post: Discourse.Post.create({id: 123})}); @@ -172,8 +172,8 @@ asyncTestDiscourse('importQuote with a post', function() { asyncTestDiscourse('importQuote with no post', function() { expect(1); - sandbox.stub(Discourse.Post, 'load').withArgs(4).returns(Em.Deferred.promise(function (p) { - p.resolve(Discourse.Post.create({raw: 'quote me'})); + sandbox.stub(Discourse.Post, 'load').withArgs(4).returns(new Ember.RSVP.Promise(function (resolve) { + resolve(Discourse.Post.create({raw: 'quote me'})); })); var composer = Discourse.Composer.create({topic: Discourse.Topic.create()}); diff --git a/test/javascripts/models/post-test.js.es6 b/test/javascripts/models/post-test.js.es6 index 45e4d84340c..4b5359f9d67 100644 --- a/test/javascripts/models/post-test.js.es6 +++ b/test/javascripts/models/post-test.js.es6 @@ -56,15 +56,13 @@ test('hasHistory', function() { test('destroy by staff', function() { - var user = Discourse.User.create({username: 'staff', staff: true}); - var post = buildPost({user: user}); + var user = Discourse.User.create({username: 'staff', staff: true}), + post = buildPost({user: user}); - sandbox.stub(Discourse, 'ajax').returns(new Em.Deferred()); post.destroy(user); present(post.get('deleted_at'), "it has a `deleted_at` field."); equal(post.get('deleted_by'), user, "it has the user in the `deleted_by` field"); - ok(Discourse.ajax.calledOnce, "it made an AJAX call"); post.recover(); blank(post.get('deleted_at'), "it clears `deleted_at` when recovering"); @@ -73,16 +71,14 @@ test('destroy by staff', function() { }); test('destroy by non-staff', function() { - var originalCooked = "this is the original cooked value"; - var user = Discourse.User.create({username: 'evil trout'}); - var post = buildPost({user: user, cooked: originalCooked}); + var originalCooked = "this is the original cooked value", + user = Discourse.User.create({username: 'evil trout'}), + post = buildPost({user: user, cooked: originalCooked}); - sandbox.stub(Discourse, 'ajax'); post.destroy(user); ok(!post.get('can_delete'), "the post can't be deleted again in this session"); ok(post.get('cooked') !== originalCooked, "the cooked content changed"); equal(post.get('version'), 2, "the version number increased"); - ok(Discourse.ajax.calledOnce, "it made an AJAX call"); });