mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Many bugs with admin badges interface
* Editing a badge's title would show it as changed in the side even if you didn't hit save * Clicking a badge would not scroll to the top * If there was an error saving a badge there was a missing i18n key * URLs were using queryParams instead of paths * User `label` tags for checkboxes for larger click targets * Saved! text would persist when viewing another badge * After creating a new badge it would show nothing * Validation errors were not being properly released to the client * Query errors were surrounded by an extra array
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
moduleFor("controller:admin-badges", "controller:admin-badges", {
|
||||
needs: ['controller:modal', 'controller:admin-badge']
|
||||
});
|
||||
|
||||
test("canEditDescription", function() {
|
||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"});
|
||||
var controller = this.subject({ model: [badge] });
|
||||
controller.send('selectBadge', badge);
|
||||
ok(controller.get('canEditDescription'), "allows editing description when a translation exists for the badge name");
|
||||
|
||||
badge.set('translatedDescription', 'translated');
|
||||
ok(!controller.get('canEditDescription'), "can't edit the description when it's got a translation");
|
||||
});
|
||||
|
||||
test("createNewBadge", function() {
|
||||
var controller = this.subject();
|
||||
controller.send('createNewBadge');
|
||||
equal(controller.get('model.length'), 1, "adds a new badge to the list of badges");
|
||||
});
|
||||
|
||||
test("selectBadge", function() {
|
||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||
controller = this.subject({ model: [badge] });
|
||||
|
||||
controller.send('selectBadge', badge);
|
||||
equal(controller.get('selectedItem'), badge, "the badge is selected");
|
||||
});
|
||||
|
||||
test("save", function() {
|
||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
||||
controller = this.subject({ model: [badge, otherBadge] });
|
||||
|
||||
controller.send('selectBadge', badge);
|
||||
sandbox.stub(badge, "save").returns(Ember.RSVP.resolve({}));
|
||||
controller.send("save");
|
||||
ok(badge.save.calledOnce, "called save on the badge");
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
||||
controller = this.subject({model: [badge, otherBadge]});
|
||||
|
||||
sandbox.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
|
||||
|
||||
bootbox.confirm = function(text, yes, no, func) {
|
||||
func(false);
|
||||
};
|
||||
|
||||
controller.send('selectBadge', badge);
|
||||
controller.send('destroy');
|
||||
ok(!badge.destroy.calledOnce, "badge is not destroyed if they user clicks no");
|
||||
|
||||
bootbox.confirm = function(text, yes, no, func) {
|
||||
func(true);
|
||||
};
|
||||
|
||||
controller.send('selectBadge', badge);
|
||||
controller.send('destroy');
|
||||
ok(badge.destroy.calledOnce, "badge is destroyed if they user clicks yes");
|
||||
});
|
||||
Reference in New Issue
Block a user