diff --git a/test/api/v2/register/POST-register.test.js b/test/api/v2/register/POST-register.test.js index e40963830e..a4d1987002 100644 --- a/test/api/v2/register/POST-register.test.js +++ b/test/api/v2/register/POST-register.test.js @@ -240,4 +240,55 @@ describe('POST /register', () => { }); }); }); + + context('successful login with habitica-android header', () => { + let api, username, email, password; + + beforeEach(() => { + api = requester({}, {'x-client': 'habitica-android'}); + username = generateRandomUserName(); + email = `${username}@example.com`; + password = 'password'; + }); + + it('sets all common tutorial flags to true', () => { + return api.post('/register', { + username: username, + email: email, + password: password, + confirmPassword: password, + }).then((user) => { + expect(user.flags.tour).to.not.be.empty; + + each(user.flags.tutorial.common, (value, attribute) => { + expect(value).to.eql(true); + }); + }); + }); + + it('populates user with default todos, habits, and rewards', () => { + return api.post('/register', { + username: username, + email: email, + password: password, + confirmPassword: password, + }).then((user) => { + expect(user.todos).to.not.be.empty; + expect(user.dailys).to.be.empty; + expect(user.habits).to.not.be.empty; + expect(user.rewards).to.not.be.empty; + }); + }); + + it('populates user with default tags', () => { + return api.post('/register', { + username: username, + email: email, + password: password, + confirmPassword: password, + }).then((user) => { + expect(user.tags).to.not.be.empty; + }); + }); + }); }); diff --git a/website/src/models/user.js b/website/src/models/user.js index 85f1e998c4..cca59d7719 100644 --- a/website/src/models/user.js +++ b/website/src/models/user.js @@ -585,7 +585,7 @@ UserSchema.methods.unlink = function(options, cb) { function _populateDefaultsForNewUser(user) { var taskTypes; - if (user.registeredThrough === "habitica-web") { + if (user.registeredThrough === "habitica-web" || user.registeredThrough === "habitica-android") { taskTypes = ['habits', 'dailys', 'todos', 'rewards', 'tags']; var tutorialCommonSections = [