mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 07:53:43 +08:00
FIX: ZALGO test suite was causing failures in the wrong place due to
missing `async` bits.
This commit is contained in:
parent
617b4bed41
commit
fdb751296a
|
@ -62,14 +62,18 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
**/
|
**/
|
||||||
updateFromJson: function(json) {
|
updateFromJson: function(json) {
|
||||||
var self = this;
|
var self = this;
|
||||||
Object.keys(json.badge).forEach(function(key) {
|
if (json.badge) {
|
||||||
self.set(key, json.badge[key]);
|
Object.keys(json.badge).forEach(function(key) {
|
||||||
});
|
self.set(key, json.badge[key]);
|
||||||
json.badge_types.forEach(function(badgeType) {
|
});
|
||||||
if (badgeType.id === self.get('badge_type_id')) {
|
}
|
||||||
self.set('badge_type', Object.create(badgeType));
|
if (json.badge_types) {
|
||||||
}
|
json.badge_types.forEach(function(badgeType) {
|
||||||
});
|
if (badgeType.id === self.get('badge_type_id')) {
|
||||||
|
self.set('badge_type', Object.create(badgeType));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,26 +17,32 @@ test('createFromJson array', function() {
|
||||||
equal(userBadges[0].get('granted_by'), null, "granted_by reference is not set when null");
|
equal(userBadges[0].get('granted_by'), null, "granted_by reference is not set when null");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('findByUsername', function() {
|
asyncTestDiscourse('findByUsername', function() {
|
||||||
|
expect(2);
|
||||||
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(multipleBadgesJson));
|
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(multipleBadgesJson));
|
||||||
Discourse.UserBadge.findByUsername("anne3").then(function(badges) {
|
Discourse.UserBadge.findByUsername("anne3").then(function(badges) {
|
||||||
ok(Array.isArray(badges), "returns an array");
|
ok(Array.isArray(badges), "returns an array");
|
||||||
|
start();
|
||||||
});
|
});
|
||||||
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('findByBadgeId', function() {
|
asyncTestDiscourse('findByBadgeId', function() {
|
||||||
|
expect(2);
|
||||||
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(multipleBadgesJson));
|
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(multipleBadgesJson));
|
||||||
Discourse.UserBadge.findByBadgeId(880).then(function(badges) {
|
Discourse.UserBadge.findByBadgeId(880).then(function(badges) {
|
||||||
ok(Array.isArray(badges), "returns an array");
|
ok(Array.isArray(badges), "returns an array");
|
||||||
|
start();
|
||||||
});
|
});
|
||||||
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('grant', function() {
|
asyncTestDiscourse('grant', function() {
|
||||||
|
expect(2);
|
||||||
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(singleBadgeJson));
|
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(singleBadgeJson));
|
||||||
Discourse.UserBadge.grant(1, "username").then(function(userBadge) {
|
Discourse.UserBadge.grant(1, "username").then(function(userBadge) {
|
||||||
ok(!Array.isArray(userBadge), "does not return an array");
|
ok(!Array.isArray(userBadge), "does not return an array");
|
||||||
|
start();
|
||||||
});
|
});
|
||||||
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user