mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 03:21:02 +08:00
FIX: preference page error when badges are disabled
This commit is contained in:
parent
1b351a3355
commit
d7ea6f93e7
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user