FIX: Reset email preferences controller. (#6316)

This commit is contained in:
Bianca Nenciu 2018-08-29 23:10:56 +02:00 committed by Régis Hanol
parent afec673c2b
commit c1a5a7504e
3 changed files with 31 additions and 0 deletions

View File

@ -20,6 +20,16 @@ export default Ember.Controller.extend({
),
unchanged: propertyEqual("newEmailLower", "currentUser.email"),
reset: function() {
this.setProperties({
taken: false,
saving: false,
error: false,
success: false,
newEmail: null
});
},
newEmailLower: function() {
return this.get("newEmail")
.toLowerCase()

View File

@ -12,6 +12,7 @@ export default RestrictedUserRoute.extend({
},
setupController: function(controller, model) {
controller.reset();
controller.setProperties({ model: model, newEmail: model.get("email") });
},

View File

@ -27,6 +27,12 @@ acceptance("User Preferences", {
});
});
server.put("/u/eviltrout/preferences/email", () => {
return helper.response({
success: true
});
});
server.post("/user_avatar/eviltrout/refresh_gravatar.json", () => {
return helper.response({
gravatar_upload_id: 6543,
@ -119,6 +125,20 @@ QUnit.test("email", async assert => {
);
});
QUnit.test("email field always shows up", async assert => {
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "eviltrout@discourse.org");
await click(".user-preferences button.btn-primary");
await visit("/u/eviltrout/preferences");
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
});
QUnit.test("connected accounts", async assert => {
await visit("/u/eviltrout/preferences/account");