mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Merge branch 'play-in-the-sandbox' into sabrecat/analytics-service
This commit is contained in:
@@ -882,6 +882,7 @@ api.wrap = (user, main=true) ->
|
|||||||
# the same seed would give one of the first five foods only.
|
# the same seed would give one of the first five foods only.
|
||||||
eligibleEquipment = _.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !user.items.gear.owned[i.key]))
|
eligibleEquipment = _.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !user.items.gear.owned[i.key]))
|
||||||
if !_.isEmpty(eligibleEquipment) and (armoireResult < .6 or !user.flags.armoireOpened)
|
if !_.isEmpty(eligibleEquipment) and (armoireResult < .6 or !user.flags.armoireOpened)
|
||||||
|
eligibleEquipment.sort() # https://github.com/HabitRPG/habitrpg/issues/5376#issuecomment-111799217
|
||||||
drop = user.fns.randomVal(eligibleEquipment)
|
drop = user.fns.randomVal(eligibleEquipment)
|
||||||
user.items.gear.owned[drop.key] = true
|
user.items.gear.owned[drop.key] = true
|
||||||
user.flags.armoireOpened = true
|
user.flags.armoireOpened = true
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
/**
|
// var migrationName = '20150604_ultimateGearSets';
|
||||||
* Created by Sabe on 6/3/2015.
|
// var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||||
*/
|
// var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||||
|
|
||||||
var migrationName = '20150604_ultimateGearSets';
|
var migrationName = '20150620_ultimateGearSets';
|
||||||
var authorName = process.env.AUTHOR_NAME || 'Sabe'; // in case script author needs to know when their ...
|
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||||
var authorUuid = process.env.AUTHOR_UUID || '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* grant the new ultimateGearSets achievement for existing users' collected equipment
|
* grant the new ultimateGearSets achievement for existing users' collected equipment
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Changed by Alys on 20150620 to assign false values to
|
||||||
|
* 'achievements.ultimateGearSets' when true values are not appropriate,
|
||||||
|
* because of https://github.com/HabitRPG/habitrpg/issues/5427
|
||||||
|
*
|
||||||
|
* Minimal changes were made so the code isn't as efficient or clean
|
||||||
|
* as it could be, but it's (hopefully) one-use-only and minimal changes
|
||||||
|
* means minimal new testing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var dbserver = 'localhost:27017' // FOR TEST DATABASE
|
var dbserver = 'localhost:27017' // FOR TEST DATABASE
|
||||||
@@ -24,25 +33,10 @@ var fields = {
|
|||||||
'items.gear.owned':1
|
'items.gear.owned':1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Changes 20150620: All users have to be processed now (non-achievers need
|
||||||
|
// false values).
|
||||||
var query = {
|
var query = {
|
||||||
// 'auth.timestamps.loggedin':{$lte:new Date('2015-05-22')},
|
|
||||||
$or: [
|
|
||||||
{'items.gear.owned.weapon_wizard_6': {$exists: true}},
|
|
||||||
{'items.gear.owned.armor_wizard_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.head_wizard_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.weapon_warrior_6': {$exists: true}},
|
|
||||||
{'items.gear.owned.armor_warrior_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.head_warrior_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.shield_warrior_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.weapon_healer_6': {$exists: true}},
|
|
||||||
{'items.gear.owned.armor_healer_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.head_healer_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.shield_healer_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.weapon_rogue_6': {$exists: true}},
|
|
||||||
{'items.gear.owned.armor_rogue_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.head_rogue_5': {$exists: true}},
|
|
||||||
{'items.gear.owned.shield_rogue_6': {$exists: true}}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
console.warn('Updating users...');
|
console.warn('Updating users...');
|
||||||
@@ -58,6 +52,8 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
|||||||
|
|
||||||
var achievements = {};
|
var achievements = {};
|
||||||
var changeUser = false;
|
var changeUser = false;
|
||||||
|
// Changes 20150620: 'changeUser' now indicates that the user must have the
|
||||||
|
// Enchanted Armoire unlocked.
|
||||||
if ( (typeof user.items.gear.owned.weapon_wizard_6 !== 'undefined')
|
if ( (typeof user.items.gear.owned.weapon_wizard_6 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.armor_wizard_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.armor_wizard_5 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.head_wizard_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.head_wizard_5 !== 'undefined')
|
||||||
@@ -65,6 +61,11 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
|||||||
achievements['wizard'] = true;
|
achievements['wizard'] = true;
|
||||||
changeUser = true;
|
changeUser = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Changes 20150620: false added for all classes (here and below)
|
||||||
|
achievements['wizard'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( (typeof user.items.gear.owned.weapon_warrior_6 !== 'undefined')
|
if ( (typeof user.items.gear.owned.weapon_warrior_6 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.armor_warrior_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.armor_warrior_5 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.head_warrior_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.head_warrior_5 !== 'undefined')
|
||||||
@@ -73,6 +74,10 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
|||||||
achievements['warrior'] = true;
|
achievements['warrior'] = true;
|
||||||
changeUser = true;
|
changeUser = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
achievements['warrior'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( (typeof user.items.gear.owned.weapon_healer_6 !== 'undefined')
|
if ( (typeof user.items.gear.owned.weapon_healer_6 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.armor_healer_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.armor_healer_5 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.head_healer_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.head_healer_5 !== 'undefined')
|
||||||
@@ -81,6 +86,10 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
|||||||
achievements['healer'] = true;
|
achievements['healer'] = true;
|
||||||
changeUser = true;
|
changeUser = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
achievements['healer'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( (typeof user.items.gear.owned.weapon_rogue_6 !== 'undefined')
|
if ( (typeof user.items.gear.owned.weapon_rogue_6 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.armor_rogue_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.armor_rogue_5 !== 'undefined')
|
||||||
&& (typeof user.items.gear.owned.head_rogue_5 !== 'undefined')
|
&& (typeof user.items.gear.owned.head_rogue_5 !== 'undefined')
|
||||||
@@ -89,12 +98,17 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
|||||||
achievements['rogue'] = true;
|
achievements['rogue'] = true;
|
||||||
changeUser = true;
|
changeUser = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (changeUser) {
|
achievements['rogue'] = false;
|
||||||
var set = {'migration':migrationName, 'achievements.ultimateGearSets':achievements, 'flags.armoireEnabled':true};
|
|
||||||
dbUsers.update({_id:user._id}, {$set:set});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Changes 20150620: $set is now run for all users.
|
||||||
|
var set = {'migration':migrationName, 'achievements.ultimateGearSets':achievements};
|
||||||
|
if (changeUser) { // user has at least one Ultimate Gear achievement
|
||||||
|
set['flags.armoireEnabled'] = true;
|
||||||
|
}
|
||||||
|
dbUsers.update({_id:user._id}, {$set:set});
|
||||||
|
|
||||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||||
if (user._id == '9' ) console.warn('lefnire' + ' processed');
|
if (user._id == '9' ) console.warn('lefnire' + ' processed');
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
"www.habitrpg.com"
|
"www.habitrpg.com"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "0.10.x"
|
"node": "0.12.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/gulp test",
|
"test": "./node_modules/.bin/gulp test",
|
||||||
|
|||||||
114
test/api/score.coffee
Normal file
114
test/api/score.coffee
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
require("../../website/src/server")
|
||||||
|
|
||||||
|
describe "Score", ->
|
||||||
|
before (done) ->
|
||||||
|
registerNewUser done, true
|
||||||
|
|
||||||
|
context "Todos that did not previously exist", ->
|
||||||
|
it "creates a completed a todo when using up url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks/withUp/up").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "withUp"
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/withUp").end (res) ->
|
||||||
|
upTodo = res.body
|
||||||
|
expect(upTodo.completed).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "creates an uncompleted todo when using down url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks/withDown/down").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "withDown"
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/withDown").end (res) ->
|
||||||
|
downTodo = res.body
|
||||||
|
expect(downTodo.completed).to.equal false
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "creates a completed a todo overriding the complete parameter when using up url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks/withUpWithComplete/up").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "withUpWithComplete"
|
||||||
|
completed: false
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/withUpWithComplete").end (res) ->
|
||||||
|
upTodo = res.body
|
||||||
|
expect(upTodo.completed).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "Creates an uncompleted todo overriding the completed parameter when using down url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks/withDownWithUncomplete/down").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "withDownWithUncomplete"
|
||||||
|
completed: true
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/withDownWithUncomplete").end (res) ->
|
||||||
|
downTodo = res.body
|
||||||
|
expect(downTodo.completed).to.equal false
|
||||||
|
done()
|
||||||
|
|
||||||
|
context "Todo that already exists", ->
|
||||||
|
it "It completes a todo when using up url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "Sample Todo"
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
unCompletedTodo = res.body
|
||||||
|
expect(unCompletedTodo.completed).to.equal false
|
||||||
|
request.post(baseURL + "/user/tasks/"+unCompletedTodo._id+"/up").end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/"+unCompletedTodo._id).end (res) ->
|
||||||
|
unCompletedTodo = res.body
|
||||||
|
expect(unCompletedTodo.completed).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "It uncompletes a todo when using down url", (done) ->
|
||||||
|
request.post(baseURL + "/user/tasks").send(
|
||||||
|
type: "todo"
|
||||||
|
text: "Sample Todo"
|
||||||
|
completed: true
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
completedTodo = res.body
|
||||||
|
expect(completedTodo.completed).to.equal true
|
||||||
|
request.post(baseURL + "/user/tasks/"+completedTodo._id+"/down").end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/"+completedTodo._id).end (res) ->
|
||||||
|
completedTodo = res.body
|
||||||
|
expect(completedTodo.completed).to.equal false
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "Creates and scores up a habit when using up url", (done) ->
|
||||||
|
upHabit = undefined
|
||||||
|
request.post(baseURL + "/user/tasks/habitWithUp/up").send(
|
||||||
|
type: "habit"
|
||||||
|
text: "testTitle"
|
||||||
|
completed: true
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/habitWithUp").end (res) ->
|
||||||
|
upHabit = res.body
|
||||||
|
expect(upHabit.value).to.be.at.least(1)
|
||||||
|
expect(upHabit.type).to.equal("habit")
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "Creates and scores down a habit when using down url", (done) ->
|
||||||
|
downHabit = undefined
|
||||||
|
request.post(baseURL + "/user/tasks/habitWithDown/down").send(
|
||||||
|
type: "habit"
|
||||||
|
text: "testTitle"
|
||||||
|
completed: true
|
||||||
|
).end (res) ->
|
||||||
|
expectCode res, 200
|
||||||
|
request.get(baseURL + "/user/tasks/habitWithDown").end (res) ->
|
||||||
|
downHabit = res.body
|
||||||
|
expect(downHabit.value).to.have.at.most(-1)
|
||||||
|
expect(downHabit.type).to.equal("habit")
|
||||||
|
done()
|
||||||
@@ -183,4 +183,3 @@ describe "Todos", ->
|
|||||||
body = res.body
|
body = res.body
|
||||||
expect(body.err).to.equal "Task not found."
|
expect(body.err).to.equal "Task not found."
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,8 @@ describe('AppJS', function() {
|
|||||||
describe('Automatic page refresh', function(){
|
describe('Automatic page refresh', function(){
|
||||||
var clock;
|
var clock;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
clock = sinon.useFakeTimers();
|
clock = sandbox.useFakeTimers();
|
||||||
sinon.stub(window, "refresher", function(){return true});
|
sandbox.stub(window, "refresher", function(){return true});
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
clock.restore();
|
|
||||||
window.refresher.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call refresher if idle time is less than 6 hours', function() {
|
it('should not call refresher if idle time is less than 6 hours', function() {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ describe('Auth Controller', function() {
|
|||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
scope.loginUsername = 'user';
|
scope.loginUsername = 'user';
|
||||||
scope.loginPassword = 'pass';
|
scope.loginPassword = 'pass';
|
||||||
$window = { location: { href: ""}, alert: sinon.spy() };
|
$window = { location: { href: ""}, alert: sandbox.spy() };
|
||||||
user = { user: {}, authenticate: sinon.spy() };
|
user = { user: {}, authenticate: sandbox.spy() };
|
||||||
|
|
||||||
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
||||||
}));
|
}));
|
||||||
@@ -20,16 +20,16 @@ describe('Auth Controller', function() {
|
|||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
||||||
scope.auth();
|
scope.auth();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
sinon.assert.calledOnce(user.authenticate);
|
expect(user.authenticate).to.be.calledOnce;
|
||||||
sinon.assert.notCalled($window.alert);
|
expect($window.alert).to.not.be.called;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not log in users with incorrect uname / pass', function() {
|
it('should not log in users with incorrect uname / pass', function() {
|
||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
||||||
scope.auth();
|
scope.auth();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
sinon.assert.notCalled(user.authenticate);
|
expect(user.authenticate).to.not.be.called;
|
||||||
sinon.assert.calledOnce($window.alert);
|
expect($window.alert).to.be.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe('Groups Controller', function() {
|
|||||||
party.type = 'party';
|
party.type = 'party';
|
||||||
party.members = []; // Ensure we wouldn't pass automatically.
|
party.members = []; // Ensure we wouldn't pass automatically.
|
||||||
|
|
||||||
var partyStub = sinon.stub(groups,"party", function() {
|
var partyStub = sandbox.stub(groups,"party", function() {
|
||||||
return party;
|
return party;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ describe('Groups Controller', function() {
|
|||||||
guild.type = 'guild';
|
guild.type = 'guild';
|
||||||
guild.members.push(user._id);
|
guild.members.push(user._id);
|
||||||
|
|
||||||
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
||||||
return [guild];
|
return [guild];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ describe('Groups Controller', function() {
|
|||||||
guild._id = "unique-guild-id";
|
guild._id = "unique-guild-id";
|
||||||
guild.type = 'guild';
|
guild.type = 'guild';
|
||||||
|
|
||||||
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ describe("Chat Controller", function() {
|
|||||||
name: "Princess Bride"
|
name: "Princess Bride"
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalSpy = sinon.spy($rootScope, "openModal");
|
var modalSpy = sandbox.spy($rootScope, "openModal");
|
||||||
var message = {
|
var message = {
|
||||||
uuid: 'the-dread-pirate-roberts',
|
uuid: 'the-dread-pirate-roberts',
|
||||||
user: 'Wesley',
|
user: 'Wesley',
|
||||||
@@ -120,7 +120,7 @@ describe("Chat Controller", function() {
|
|||||||
name: "Princess Bride"
|
name: "Princess Bride"
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalSpy = sinon.spy($rootScope, "openModal");
|
var modalSpy = sandbox.spy($rootScope, "openModal");
|
||||||
var message = {
|
var message = {
|
||||||
uuid: 'system',
|
uuid: 'system',
|
||||||
text: 'Wesley attacked the ROUS in the Fire Swamp'
|
text: 'Wesley attacked the ROUS in the Fire Swamp'
|
||||||
@@ -221,7 +221,7 @@ describe("Autocomplete controller", function() {
|
|||||||
|
|
||||||
describe("performCompletion", function() {
|
describe("performCompletion", function() {
|
||||||
it('triggers autoComplete', function() {
|
it('triggers autoComplete', function() {
|
||||||
scope.autoComplete = sinon.spy();
|
scope.autoComplete = sandbox.spy();
|
||||||
|
|
||||||
var msg = {user: "boo"}; // scope.autoComplete only cares about user
|
var msg = {user: "boo"}; // scope.autoComplete only cares about user
|
||||||
scope.query = {text: "b"};
|
scope.query = {text: "b"};
|
||||||
@@ -247,7 +247,7 @@ describe("Autocomplete controller", function() {
|
|||||||
|
|
||||||
describe("chatChanged", function() {
|
describe("chatChanged", function() {
|
||||||
it('if a new chat arrives, the new user name is extracted', function() {
|
it('if a new chat arrives, the new user name is extracted', function() {
|
||||||
var chatChanged = sinon.spy(scope, 'chatChanged');
|
var chatChanged = sandbox.spy(scope, 'chatChanged');
|
||||||
scope.$watch('group.chat',scope.chatChanged); // reinstantiate watch so spy works
|
scope.$watch('group.chat',scope.chatChanged); // reinstantiate watch so spy works
|
||||||
|
|
||||||
scope.$digest(); // trigger watch
|
scope.$digest(); // trigger watch
|
||||||
@@ -269,11 +269,11 @@ describe("CopyMessageModal controller", function() {
|
|||||||
user = specHelper.newUser();
|
user = specHelper.newUser();
|
||||||
user._id = "unique-user-id";
|
user._id = "unique-user-id";
|
||||||
user.ops = {
|
user.ops = {
|
||||||
addTask: sinon.spy()
|
addTask: sandbox.spy()
|
||||||
};
|
};
|
||||||
|
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
scope.$close = sinon.spy();
|
scope.$close = sandbox.spy();
|
||||||
|
|
||||||
$controller = _$controller_;
|
$controller = _$controller_;
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ describe("CopyMessageModal controller", function() {
|
|||||||
ctrl = $controller('CopyMessageModalCtrl', {$scope: scope, User: {user: user}});
|
ctrl = $controller('CopyMessageModalCtrl', {$scope: scope, User: {user: user}});
|
||||||
|
|
||||||
Notification = _Notification_;
|
Notification = _Notification_;
|
||||||
Notification.text = sinon.spy();
|
Notification.text = sandbox.spy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,12 @@ describe('Hall of Heroes Controller', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('populates contributor input with selected hero id', function(){
|
it('populates contributor input with selected hero id', function(){
|
||||||
var loadHero = sinon.spy(scope, "loadHero");
|
var loadHero = sandbox.spy(scope, "loadHero");
|
||||||
var scrollTo = sinon.spy(window, "scrollTo");
|
var scrollTo = sandbox.spy(window, "scrollTo");
|
||||||
|
|
||||||
scope.populateContributorInput(user._id);
|
scope.populateContributorInput(user._id);
|
||||||
expect(scope._heroID).to.eql(user._id);
|
expect(scope._heroID).to.eql(user._id);
|
||||||
expect(loadHero.callCount).to.eql(1);
|
expect(loadHero.callCount).to.eql(1);
|
||||||
expect(scrollTo.callCount).to.eql(1);
|
expect(scrollTo.callCount).to.eql(1);
|
||||||
|
|
||||||
scope.loadHero.restore();
|
|
||||||
window.scrollTo.restore();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,13 +26,8 @@ describe('Header Controller', function() {
|
|||||||
|
|
||||||
context('inviteOrStartParty', function(){
|
context('inviteOrStartParty', function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
sinon.stub($location, 'path');
|
sandbox.stub($location, 'path');
|
||||||
sinon.stub($rootScope, 'openModal');
|
sandbox.stub($rootScope, 'openModal');
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function(){
|
|
||||||
$location.path.restore();
|
|
||||||
$rootScope.openModal.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('redirects to party page if user does not have a party', function(){
|
it('redirects to party page if user does not have a party', function(){
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ describe('Root Controller', function() {
|
|||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
|
|
||||||
notification = Notification;
|
notification = Notification;
|
||||||
sinon.stub(notification, 'text');
|
sandbox.stub(notification, 'text');
|
||||||
sinon.stub(notification, 'markdown');
|
sandbox.stub(notification, 'markdown');
|
||||||
|
|
||||||
user = specHelper.newUser();
|
user = specHelper.newUser();
|
||||||
User = {user: user};
|
User = {user: user};
|
||||||
User.save = sinon.spy();
|
User.save = sandbox.spy();
|
||||||
User.sync = sinon.spy();
|
User.sync = sandbox.spy();
|
||||||
|
|
||||||
$httpBackend.whenGET(/partials/).respond();
|
$httpBackend.whenGET(/partials/).respond();
|
||||||
|
|
||||||
@@ -38,13 +38,6 @@ describe('Root Controller', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
notification.text.reset();
|
|
||||||
notification.markdown.reset();
|
|
||||||
User.save.reset();
|
|
||||||
User.sync.reset();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('contribText', function(){
|
describe('contribText', function(){
|
||||||
it('shows contributor level text', function(){
|
it('shows contributor level text', function(){
|
||||||
expect(scope.contribText()).to.eql(undefined);
|
expect(scope.contribText()).to.eql(undefined);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('focusMe Directive', function() {
|
|||||||
|
|
||||||
it('focuses the element when appended to the DOM', function() {
|
it('focuses the element when appended to the DOM', function() {
|
||||||
inject(function($timeout) {
|
inject(function($timeout) {
|
||||||
var focusSpy = sinon.spy();
|
var focusSpy = sandbox.spy();
|
||||||
|
|
||||||
element.appendTo(document.body);
|
element.appendTo(document.body);
|
||||||
element.on('focus', focusSpy);
|
element.on('focus', focusSpy);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('fromNow Directive', function() {
|
|||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
scope.message = {};
|
scope.message = {};
|
||||||
|
|
||||||
sinon.stub(window, 'moment').returns({
|
sandbox.stub(window, 'moment').returns({
|
||||||
fromNow: function() { return fromNow },
|
fromNow: function() { return fromNow },
|
||||||
diff: function() { return diff }
|
diff: function() { return diff }
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Task Ordering Filters', function() {
|
describe('Task Ordering Filters', function() {
|
||||||
var filter
|
var filter, orderBySpy;
|
||||||
, orderBySpy = sinon.spy();
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
orderBySpy = sandbox.spy();
|
||||||
|
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
$provide.value('orderByFilter', orderBySpy);
|
$provide.value('orderByFilter', orderBySpy);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,9 +4,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Analytics Service', function () {
|
describe('Analytics Service', function () {
|
||||||
var analytics;
|
var analytics, user;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
user = specHelper.newUser();
|
||||||
|
user.contributor = { level: 1 };
|
||||||
|
user.purchased = { plan: true };
|
||||||
|
|
||||||
|
module(function($provide) {
|
||||||
|
$provide.value('User', {user: user});
|
||||||
|
});
|
||||||
|
|
||||||
inject(function(Analytics) {
|
inject(function(Analytics) {
|
||||||
analytics = Analytics;
|
analytics = Analytics;
|
||||||
});
|
});
|
||||||
@@ -15,11 +23,7 @@ describe('Analytics Service', function () {
|
|||||||
context('error handling', function() {
|
context('error handling', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(console, 'log');
|
sandbox.stub(console, 'log');
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
console.log.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not accept tracking events without required properties', function() {
|
it('does not accept tracking events without required properties', function() {
|
||||||
@@ -42,15 +46,9 @@ describe('Analytics Service', function () {
|
|||||||
context('Amplitude', function() {
|
context('Amplitude', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(amplitude, 'setUserId');
|
sandbox.stub(amplitude, 'setUserId');
|
||||||
sinon.stub(amplitude, 'logEvent');
|
sandbox.stub(amplitude, 'logEvent');
|
||||||
sinon.stub(amplitude, 'setUserProperties');
|
sandbox.stub(amplitude, 'setUserProperties');
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
amplitude.setUserId.restore();
|
|
||||||
amplitude.logEvent.restore();
|
|
||||||
amplitude.setUserProperties.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets up tracking when user registers', function() {
|
it('sets up tracking when user registers', function() {
|
||||||
@@ -85,11 +83,7 @@ describe('Analytics Service', function () {
|
|||||||
context('Google Analytics', function() {
|
context('Google Analytics', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(window, 'ga');
|
sandbox.stub(window, 'ga');
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
window.ga.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets up tracking when user registers', function() {
|
it('sets up tracking when user registers', function() {
|
||||||
@@ -126,17 +120,10 @@ describe('Analytics Service', function () {
|
|||||||
context.skip('Mixpanel', function() { // Mixpanel not currently in use
|
context.skip('Mixpanel', function() { // Mixpanel not currently in use
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(mixpanel, 'alias');
|
sandbox.stub(mixpanel, 'alias');
|
||||||
sinon.stub(mixpanel, 'identify');
|
sandbox.stub(mixpanel, 'identify');
|
||||||
sinon.stub(mixpanel, 'track');
|
sandbox.stub(mixpanel, 'track');
|
||||||
sinon.stub(mixpanel, 'register');
|
sandbox.stub(mixpanel, 'register');
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
mixpanel.alias.restore();
|
|
||||||
mixpanel.identify.restore();
|
|
||||||
mixpanel.track.restore();
|
|
||||||
mixpanel.register.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets up tracking when user registers', function() {
|
it('sets up tracking when user registers', function() {
|
||||||
|
|||||||
@@ -3,13 +3,11 @@
|
|||||||
describe('notificationServices', function() {
|
describe('notificationServices', function() {
|
||||||
var notification;
|
var notification;
|
||||||
|
|
||||||
before(function(){
|
beforeEach(function() {
|
||||||
sinon.stub($, 'pnotify', function(){
|
sandbox.stub($, 'pnotify', function(){
|
||||||
return { click: function(){}}
|
return { click: function(){}}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
module(function($provide){
|
module(function($provide){
|
||||||
$provide.value('User', {});
|
$provide.value('User', {});
|
||||||
});
|
});
|
||||||
@@ -19,10 +17,6 @@ describe('notificationServices', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
$.pnotify.reset();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('notifies coins amount', function() {
|
it('notifies coins amount', function() {
|
||||||
var SILVER_COIN = "<span class='notification-icon shop_silver'></span>";
|
var SILVER_COIN = "<span class='notification-icon shop_silver'></span>";
|
||||||
var GOLD_COIN = "<span class='notification-icon shop_gold'></span>";
|
var GOLD_COIN = "<span class='notification-icon shop_gold'></span>";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe('userServices', function() {
|
|||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
module(function($provide){
|
module(function($provide){
|
||||||
$window = {href: '', alert: sinon.spy(), location: {search: '', pathname: ''}};
|
$window = {href: '', alert: sandbox.spy(), location: {search: '', pathname: ''}};
|
||||||
$provide.value('$window', $window);
|
$provide.value('$window', $window);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
beforeEach(module('habitrpg'));
|
beforeEach(module('habitrpg'));
|
||||||
|
|
||||||
|
var sandbox;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
sandbox = sinon.sandbox.create();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
sandbox.restore();
|
||||||
|
});
|
||||||
|
|
||||||
specHelper = {
|
specHelper = {
|
||||||
newUser: function(){
|
newUser: function(){
|
||||||
var buffs = {per:0, int:0, con:0, str:0, stealth: 0, streaks: false};
|
var buffs = {per:0, int:0, con:0, str:0, stealth: 0, streaks: false};
|
||||||
|
|||||||
@@ -99,9 +99,11 @@ api.score = function(req, res, next) {
|
|||||||
text: req.body && req.body.text,
|
text: req.body && req.body.text,
|
||||||
notes: (req.body && req.body.notes) || "This task was created by a third-party service. Feel free to edit, it won't harm the connection to that service. Additionally, multiple services may piggy-back off this task."
|
notes: (req.body && req.body.notes) || "This task was created by a third-party service. Feel free to edit, it won't harm the connection to that service. Additionally, multiple services may piggy-back off this task."
|
||||||
};
|
};
|
||||||
task = user.ops.addTask({body:task});
|
|
||||||
if (task.type === 'daily' || task.type === 'todo')
|
if (task.type === 'daily' || task.type === 'todo')
|
||||||
task.completed = direction === 'up';
|
task.completed = direction === 'up';
|
||||||
|
|
||||||
|
task = user.ops.addTask({body:task});
|
||||||
}
|
}
|
||||||
var delta = user.ops.score({params:{id:task.id, direction:direction}, language: req.language});
|
var delta = user.ops.score({params:{id:task.id, direction:direction}, language: req.language});
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,6 @@ var UserSchema = new Schema({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
preferences: {
|
preferences: {
|
||||||
armorSet: String,
|
|
||||||
dayStart: {type:Number, 'default': 0, min: 0, max: 23},
|
dayStart: {type:Number, 'default': 0, min: 0, max: 23},
|
||||||
size: {type:String, enum: ['broad','slim'], 'default': 'slim'},
|
size: {type:String, enum: ['broad','slim'], 'default': 'slim'},
|
||||||
hair: {
|
hair: {
|
||||||
|
|||||||
Reference in New Issue
Block a user