Upgrade Ember to 1.1.2

This commit is contained in:
Robin Ward 2013-10-29 13:01:42 -04:00
parent c9c7dc2002
commit 5689e314c5
20 changed files with 1565 additions and 1828 deletions

View File

@ -44,8 +44,8 @@ Discourse.ApiKey.reopenClass({
@param {Object} the properties to create
@returns {Discourse.ApiKey} the ApiKey instance
**/
create: function(apiKey) {
var result = this._super(apiKey);
create: function() {
var result = this._super.apply(this, arguments);
if (result.user) {
result.user = Discourse.AdminUser.create(result.user);
}

View File

@ -10,6 +10,8 @@ Discourse.EmailLog = Discourse.Model.extend({});
Discourse.EmailLog.reopenClass({
create: function(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = Discourse.AdminUser.create(attrs.user);
}

View File

@ -43,6 +43,8 @@ Discourse.StaffActionLog = Discourse.Model.extend({
Discourse.StaffActionLog.reopenClass({
create: function(attrs) {
attrs = attrs || {};
if (attrs.acting_user) {
attrs.acting_user = Discourse.AdminUser.create(attrs.acting_user);
}

View File

@ -21,9 +21,8 @@ Discourse.Invite = Discourse.Model.extend({
Discourse.Invite.reopenClass({
create: function(invite) {
var result;
result = this._super(invite);
create: function() {
var result = this._super.apply(this, arguments);
if (result.user) {
result.user = Discourse.User.create(result.user);
}

View File

@ -30,12 +30,12 @@ Discourse.Notification = Discourse.Model.extend({
Discourse.Notification.reopenClass({
create: function(obj) {
var result;
result = this._super(obj);
obj = obj || {};
if (obj.data) {
result.set('data', Em.Object.create(obj.data));
obj.data = Em.Object.create(obj.data);
}
return result;
return this._super(obj);
}
});

View File

@ -378,7 +378,7 @@ Discourse.Post.reopenClass({
},
create: function(obj) {
var result = this._super(obj);
var result = this._super.apply(this, arguments);
this.createActionSummary(result);
if (obj && obj.reply_to_user) {
result.set('reply_to_user', Discourse.User.create(obj.reply_to_user));

View File

@ -237,7 +237,7 @@ Discourse.PostStream = Em.Object.extend({
var postWeWant = this.get('posts').findProperty('post_number', opts.nearPost);
if (postWeWant) {
Discourse.TopicView.jumpToPost(topic.get('id'), opts.nearPost);
return Ember.Deferred.create(function(p) { p.reject(); });
return Ember.RSVP.reject();
}
// TODO: if we have all the posts in the filter, don't go to the server for them.
@ -301,7 +301,7 @@ Discourse.PostStream = Em.Object.extend({
**/
prependMore: function() {
var postStream = this,
rejectedPromise = Ember.Deferred.create(function(p) { p.reject(); });
rejectedPromise = Ember.RSVP.reject();
// Make sure we can append more posts
if (!postStream.get('canPrependMore')) { return rejectedPromise; }
@ -684,8 +684,8 @@ Discourse.PostStream = Em.Object.extend({
Discourse.PostStream.reopenClass({
create: function(args) {
var postStream = this._super(args);
create: function() {
var postStream = this._super.apply(this, arguments);
postStream.setProperties({
posts: Em.A(),
stream: Em.A(),

View File

@ -44,8 +44,8 @@ Discourse.Site.reopenClass(Discourse.Singleton, {
return Discourse.Site.create(PreloadStore.get('site'));
},
create: function(obj) {
var result = this._super(obj);
create: function() {
var result = this._super.apply(this, arguments);
if (result.categories) {
var byId = {};

View File

@ -20,7 +20,7 @@ function createPMRoute(viewName, path, type) {
},
setupController: function(controller, model) {
this._super(controller, model);
this._super.apply(this, arguments);
controller.set('hideCategories', true);
this.controllerFor('user').setProperties({
pmView: viewName,

View File

@ -234,16 +234,16 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
var info = Discourse.Eyeline.analyze(rows);
if(!info) { return; }
// We disable scrolling of the topic while performing initial positioning
// This code needs to be refactored, the pipline for positioning posts is wack
// Be sure to test on safari as well when playing with this
if(!Discourse.TopicView.disableScroll) {
// are we scrolling upwards?
if(info.top === 0 || info.onScreen[0] === 0 || info.bottom === 0) {
var $body = $('body');
var $elem = $(rows[0]);
var distToElement = $body.scrollTop() - $elem.position().top;
var $body = $('body'),
$elem = $(rows[0]),
distToElement = $body.scrollTop() - $elem.position().top;
this.get('postStream').prependMore().then(function() {
Em.run.next(function () {
$('html, body').scrollTop($elem.position().top + distToElement);
@ -252,6 +252,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
}
}
// are we scrolling down?
var currentPost;
if(info.bottom === rows.length-1) {

View File

@ -17,7 +17,7 @@ asyncTestDiscourse('find', function() {
});
asyncTestDiscourse('generateMasterKey', function() {
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve([]));
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {}}));
Discourse.ApiKey.generateMasterKey().then(function() {
start();
ok(Discourse.ajax.calledWith("/admin/api/key", {type: 'POST'}), "it POSTs to create a master key");

View File

@ -14,7 +14,7 @@ test("without selectedPosts", function () {
});
test("with some selectedPosts", function() {
var testObj = buildTestObj({ selectedPosts: [Discourse.Post.create()] });
var testObj = buildTestObj({ selectedPosts: [Discourse.Post.create({id: 123})] });
equal(testObj.get('selectedPostsCount'), 1, "It returns the amount of posts");
});

View File

@ -0,0 +1,5 @@
module("Discourse.EmailLog");
test("create", function() {
ok(Discourse.EmailLog.create(), "it can be created without arguments");
});

View File

@ -0,0 +1,5 @@
module("Discourse.Invite");
test("create", function() {
ok(Discourse.Invite.create(), "it can be created without arguments");
});

View File

@ -0,0 +1,5 @@
module("Discourse.Notification");
test("create", function() {
ok(Discourse.Notification.create(), "it can be created without arguments");
});

View File

@ -11,6 +11,10 @@ var buildStream = function(id, stream) {
var participant = {username: 'eviltrout'};
test('create', function() {
ok(Discourse.PostStream.create(), 'it can be created with no parameters');
});
test('defaults', function() {
var postStream = buildStream(1234);
blank(postStream.get('posts'), "there are no posts in a stream by default");

View File

@ -1,6 +1,10 @@
module("Discourse.Site");
test('instance', function(){
test('create', function() {
ok(Discourse.Site.create(), 'it can create with no parameters');
});
test('instance', function() {
var site = Discourse.Site.current();
@ -32,5 +36,4 @@ test('create categories', function() {
present(subcategory, "it loaded the subcategory");
equal(subcategory.get('parentCategory'), parent, "it has associated the child with the parent");
});

View File

@ -0,0 +1,5 @@
module("Discourse.StaffActionLog");
test("create", function() {
ok(Discourse.StaffActionLog.create(), "it can be created without arguments");
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff