FIX: preference page error when badges are disabled

This commit is contained in:
Neil Lalonde 2018-04-09 14:27:00 -04:00
parent 1b351a3355
commit d7ea6f93e7
2 changed files with 24 additions and 4 deletions

View File

@ -6,10 +6,14 @@ export default RestrictedUserRoute.extend({
model: function() {
const user = this.modelFor('user');
return UserBadge.findByUsername(this.modelFor('user').get('username')).then(userBadges => {
user.set('badges', userBadges.map(ub => ub.badge));
return user;
});
if (this.siteSettings.enable_badges) {
return UserBadge.findByUsername(this.modelFor('user').get('username')).then(userBadges => {
user.set('badges', userBadges.map(ub => ub.badge));
return user;
});
} else {
return user;
}
},
setupController(controller, user) {

View File

@ -121,3 +121,19 @@ QUnit.test("second factor", assert => {
);
});
});
acceptance("User Preferences when badges are disabled", {
loggedIn: true,
settings: {
enable_badges: false
}
});
QUnit.test("visit my preferences", assert => {
visit("/u/eviltrout/preferences");
andThen(() => {
assert.ok($('body.user-preferences-page').length, "has the body class");
assert.equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab");
assert.ok(exists('.user-preferences'), 'it shows the preferences');
});
});