Skip to content

Commit

Permalink
Merge branch 'develop' into paglias/realtime-chat-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
paglias committed Sep 9, 2016
2 parents 98df0f2 + 7d7bb3e commit e2b03ec
Show file tree
Hide file tree
Showing 63 changed files with 482 additions and 124 deletions.
10 changes: 7 additions & 3 deletions common/locales/en/defaultTasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"defaultReward1Text": "15 minute break",
"defaultReward1Notes": "Custom rewards can come in many forms. Some people will hold off watching their favorite show unless they have the gold to pay for it.",

"defaultTag1": "morning",
"defaultTag2": "afternoon",
"defaultTag3": "evening"
"defaultTag1": "Work",
"defaultTag2": "Exercise",
"defaultTag3": "Health + Wellness",
"defaultTag4": "School",
"defaultTag5": "Teams",
"defaultTag6": "Chores",
"defaultTag7": "Creativity"
}
14 changes: 14 additions & 0 deletions common/locales/en/faq.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions common/locales/en/front.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@
"presskit": "Press Kit",
"presskitDownload": "Download all images:",
"presskitText": "Thanks for your interest in Habitica! The following images can be used for articles or videos about Habitica. For more information, please contact the staff at admin@habitica.com.",
"pkVideo": "Video",
"pkPromo": "Promos",
"pkLogo": "Logos",
"pkBoss": "Bosses",
"pkSamples": "Sample Screens",
"pkWebsite": "Website",
"pkiOS": "iOS",
"pkAndroid": "Android",
"privacy": "Privacy Policy",
"psst": "Psst",
"punishByline": "Break bad habits and procrastination cycles with immediate consequences.",
Expand Down
2 changes: 1 addition & 1 deletion common/locales/en_GB/defaulttasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"defaultTag1": "morning",
"defaultTag2": "afternoon",
"defaultTag3": "evening"
}
}
8 changes: 8 additions & 0 deletions common/script/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2940,6 +2940,14 @@ api.userDefaults = {
name: t('defaultTag2')
}, {
name: t('defaultTag3')
}, {
name: t('defaultTag4')
}, {
name: t('defaultTag5')
}, {
name: t('defaultTag6')
}, {
name: t('defaultTag7')
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "3.39.1",
"version": "3.40.0",
"main": "./website/server/index.js",
"dependencies": {
"@slack/client": "slackhq/node-slack-sdk#2ee794cd31326c54f38c518eef2b9d223327d939",
"@slack/client": "3.6.0",
"accepts": "^1.3.2",
"amazon-payments": "0.0.4",
"amplitude": "^2.0.3",
Expand Down
19 changes: 19 additions & 0 deletions test/api/v3/integration/user/auth/POST-register_local.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ describe('POST /user/auth/local/register', () => {
expect(user.auth.local.username).to.eql(username);
});

it('provides default tags and tasks', async () => {
let username = generateRandomUserName();
let email = `${username}@example.com`;
let password = 'password';

let user = await api.post('/user/auth/local/register', {
username,
email,
password,
confirmPassword: password,
});

expect(user.tags).to.have.a.lengthOf(7);
expect(user.tasksOrder.todos).to.have.a.lengthOf(1);
expect(user.tasksOrder.dailys).to.have.a.lengthOf(0);
expect(user.tasksOrder.rewards).to.have.a.lengthOf(0);
expect(user.tasksOrder.habits).to.have.a.lengthOf(0);
});

it('requires password and confirmPassword to match', async () => {
let username = generateRandomUserName();
let email = `${username}@example.com`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('POST /user/auth/social', () => {
user = await generateUser();

let expectedResult = {id: facebookId};
let passportFacebookProfile = sinon.stub(passport._strategies.facebook, 'userProfile');
let passportFacebookProfile = sandbox.stub(passport._strategies.facebook, 'userProfile');
passportFacebookProfile.yields(null, expectedResult);
});

Expand Down
36 changes: 35 additions & 1 deletion test/api/v3/unit/libs/cron.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable global-require */
import moment from 'moment';
import nconf from 'nconf';
import Bluebird from 'bluebird';
import requireAgain from 'require-again';
import { recoverCron, cron } from '../../../../../website/server/libs/cron';
import { model as User } from '../../../../../website/server/models/user';
import * as Tasks from '../../../../../website/server/models/task';
Expand All @@ -9,6 +11,8 @@ import common from '../../../../../common';

// const scoreTask = common.ops.scoreTask;

let pathToCronLib = '../../../../../website/server/libs/cron';

describe('cron', () => {
let user;
let tasksByType = {habits: [], dailys: [], todos: [], rewards: []};
Expand Down Expand Up @@ -159,7 +163,7 @@ describe('cron', () => {
expect(user.purchased.plan.consecutive.trinkets).to.equal(0);
});

it('doest not increment plan.consecutive.gemCapExtra when user has reached a month that is a multiple of 3', () => {
it('does not increment plan.consecutive.gemCapExtra when user has reached a month that is a multiple of 3', () => {
user.purchased.plan.consecutive.count = 5;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.consecutive.gemCapExtra).to.equal(0);
Expand Down Expand Up @@ -319,6 +323,19 @@ describe('cron', () => {
expect(user.stats.hp).to.be.lessThan(hpBefore);
});

it('should not do damage for missing a daily when CRON_SAFE_MODE is set', () => {
sandbox.stub(nconf, 'get').withArgs('CRON_SAFE_MODE').returns('true');
let cronOverride = requireAgain(pathToCronLib).cron;

daysMissed = 1;
let hpBefore = user.stats.hp;
tasksByType.dailys[0].startDate = moment(new Date()).subtract({days: 1});

cronOverride({user, tasksByType, daysMissed, analytics});

expect(user.stats.hp).to.equal(hpBefore);
});

it('should not do damage for missing a daily if user stealth buff is greater than or equal to days missed', () => {
daysMissed = 1;
let hpBefore = user.stats.hp;
Expand Down Expand Up @@ -443,6 +460,23 @@ describe('cron', () => {
expect(user.stats.buffs.con).to.be.greaterThan(previousBuffs.con);
});

it('still grants a perfect day when CRON_SAFE_MODE is set', () => {
sandbox.stub(nconf, 'get').withArgs('CRON_SAFE_MODE').returns('true');
let cronOverride = requireAgain(pathToCronLib).cron;
daysMissed = 1;
tasksByType.dailys[0].completed = false;
tasksByType.dailys[0].startDate = moment(new Date()).subtract({days: 1});

let previousBuffs = clone(user.stats.buffs);

cronOverride({user, tasksByType, daysMissed, analytics});

expect(user.stats.buffs.str).to.be.greaterThan(previousBuffs.str);
expect(user.stats.buffs.int).to.be.greaterThan(previousBuffs.int);
expect(user.stats.buffs.per).to.be.greaterThan(previousBuffs.per);
expect(user.stats.buffs.con).to.be.greaterThan(previousBuffs.con);
});

it('clears buffs if user does not have a perfect day', () => {
daysMissed = 1;
tasksByType.dailys[0].completed = false;
Expand Down
37 changes: 35 additions & 2 deletions test/spec/controllers/inventoryCtrlSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

describe('Inventory Controller', function() {
var scope, ctrl, user, rootScope;
var scope, ctrl, user, rootScope, shared, achievement;

beforeEach(function() {
module(function($provide) {
Expand All @@ -15,7 +15,7 @@ describe('Inventory Controller', function() {
$provide.value('$window', mockWindow);
});

inject(function($rootScope, $controller, Shared, User, $location, $window) {
inject(function($rootScope, $controller, Shared, User, $location, $window, Achievement) {
user = specHelper.newUser({
balance: 4,
items: {
Expand All @@ -32,6 +32,8 @@ describe('Inventory Controller', function() {
});

Shared.wrap(user);
shared = Shared;
achievement = Achievement;

scope = $rootScope.$new();
rootScope = $rootScope;
Expand Down Expand Up @@ -118,6 +120,27 @@ describe('Inventory Controller', function() {

expect(rootScope.openModal).to.not.be.called;
});

it('shows beastMaster achievement modal if user has all 90 pets', function(){
sandbox.stub(achievement, 'displayAchievement');
sandbox.stub(shared.count, "beastMasterProgress").returns(90);
scope.chooseEgg('Cactus');
scope.choosePotion('Base');

expect(achievement.displayAchievement).to.be.called;
expect(achievement.displayAchievement).to.be.calledWith('beastMaster');
});

it('shows triadBingo achievement modal if user has all pets twice and all mounts', function(){
sandbox.stub(achievement, 'displayAchievement');
sandbox.stub(shared.count, "mountMasterProgress").returns(90);
sandbox.stub(shared.count, "dropPetsCurrentlyOwned").returns(90);
scope.chooseEgg('Cactus');
scope.choosePotion('Base');

expect(achievement.displayAchievement).to.be.called;
expect(achievement.displayAchievement).to.be.calledWith('triadBingo');
});
});

describe('Feeding and Raising Pets', function() {
Expand Down Expand Up @@ -194,6 +217,16 @@ describe('Inventory Controller', function() {
expect(rootScope.openModal).to.have.been.calledOnce;
expect(rootScope.openModal).to.have.been.calledWith('raisePet');
});

it('shows mountMaster achievement modal if user has all 90 mounts', function(){
sandbox.stub(achievement, 'displayAchievement');
sandbox.stub(shared.count, "mountMasterProgress").returns(90);
scope.chooseFood('Meat');
scope.choosePet('PandaCub','Base');

expect(achievement.displayAchievement).to.be.calledOnce;
expect(achievement.displayAchievement).to.be.calledWith('mountMaster');
});
});

it('sells an egg', function(){
Expand Down

0 comments on commit e2b03ec

Please sign in to comment.