mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: Default sort grantable badges by name
Currently has no default sort and was stated as a bug here: https://meta.discourse.org/t/badges-not-sorted-in-grant-badge-dropdown/23739 (Post was recently deleted or made private?)
This commit is contained in:
parent
b5bcf7bf3d
commit
c50205725f
2 changed files with 17 additions and 1 deletions
|
@ -32,7 +32,7 @@ export default Ember.ArrayController.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return badges;
|
return _.sortBy(badges, "name");
|
||||||
}.property('badges.@each', 'model.@each'),
|
}.property('badges.@each', 'model.@each'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
moduleFor('controller:admin-user-badges', 'Admin User Badges Controller', {
|
||||||
|
needs: ['controller:adminUser']
|
||||||
|
});
|
||||||
|
|
||||||
|
test("grantableBadges", function() {
|
||||||
|
var badge_first = Discourse.Badge.create({id: 3, name: "A Badge"});
|
||||||
|
var badge_middle = Discourse.Badge.create({id: 1, name: "My Badge"});
|
||||||
|
var badge_last = Discourse.Badge.create({id: 2, name: "Zoo Badge"});
|
||||||
|
var controller = this.subject({ badges: [badge_last, badge_first, badge_middle] });
|
||||||
|
var sorted_names = [badge_first.name, badge_middle.name, badge_last.name];
|
||||||
|
var badge_names = controller.get('grantableBadges').map(function(badge) {
|
||||||
|
return badge.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(badge_names, sorted_names, "sorts badges by name");
|
||||||
|
});
|
Loading…
Reference in a new issue