mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 12:40:40 +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) {
|
||||
var self = this;
|
||||
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) {
|
||||
Object.keys(json.badge).forEach(function(key) {
|
||||
self.set(key, json.badge[key]);
|
||||
});
|
||||
}
|
||||
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");
|
||||
});
|
||||
|
||||
test('findByUsername', function() {
|
||||
asyncTestDiscourse('findByUsername', function() {
|
||||
expect(2);
|
||||
this.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve(multipleBadgesJson));
|
||||
Discourse.UserBadge.findByUsername("anne3").then(function(badges) {
|
||||
ok(Array.isArray(badges), "returns an array");
|
||||
start();
|
||||
});
|
||||
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));
|
||||
Discourse.UserBadge.findByBadgeId(880).then(function(badges) {
|
||||
ok(Array.isArray(badges), "returns an array");
|
||||
start();
|
||||
});
|
||||
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));
|
||||
Discourse.UserBadge.grant(1, "username").then(function(userBadge) {
|
||||
ok(!Array.isArray(userBadge), "does not return an array");
|
||||
start();
|
||||
});
|
||||
ok(Discourse.ajax.calledOnce, "makes an AJAX call");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user