mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix(analytics): Bad comparison
Corrects an error caught via test, where the check for intro tour completion would always fail. Also tweaks the updateUser behavior to save an explicit false if tour completion data is not found, including a test for that behavior.
This commit is contained in:
@@ -183,6 +183,7 @@ describe('Analytics Service', function () {
|
|||||||
expectedProperties.Health = 48;
|
expectedProperties.Health = 48;
|
||||||
expectedProperties.Level = 24;
|
expectedProperties.Level = 24;
|
||||||
expectedProperties.Mana = 41;
|
expectedProperties.Mana = 41;
|
||||||
|
expectedProperties.tutorialComplete = false;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
user._id = 'unique-user-id';
|
user._id = 'unique-user-id';
|
||||||
@@ -192,6 +193,7 @@ describe('Analytics Service', function () {
|
|||||||
user.stats.hp = 47.8;
|
user.stats.hp = 47.8;
|
||||||
user.stats.lvl = 24;
|
user.stats.lvl = 24;
|
||||||
user.stats.mp = 41;
|
user.stats.mp = 41;
|
||||||
|
user.flags.tour.intro = 3;
|
||||||
|
|
||||||
analytics.updateUser(properties);
|
analytics.updateUser(properties);
|
||||||
clock.tick();
|
clock.tick();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ describe('groupServices', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
$provide.value('User', {});
|
$provide.value('User', {user:user});
|
||||||
});
|
});
|
||||||
|
|
||||||
inject(function(_$httpBackend_, Groups, User) {
|
inject(function(_$httpBackend_, Groups, User) {
|
||||||
|
|||||||
@@ -107,7 +107,8 @@
|
|||||||
properties.Level = user.stats.lvl;
|
properties.Level = user.stats.lvl;
|
||||||
properties.Mana = Math.floor(user.stats.mp);
|
properties.Mana = Math.floor(user.stats.mp);
|
||||||
}
|
}
|
||||||
if (user.flags.tour && user.flags.tour.intro === '-2') properties.tutorialComplete = true;
|
if (user.flags && user.flags.tour && user.flags.tour.intro === -2) {properties.tutorialComplete = true}
|
||||||
|
else {properties.tutorialComplete = false};
|
||||||
if (user.contributor && user.contributor.level) properties.contributorLevel = user.contributor.level;
|
if (user.contributor && user.contributor.level) properties.contributorLevel = user.contributor.level;
|
||||||
if (user.purchased && user.purchased.plan.planId) properties.subscription = user.purchased.plan.planId;
|
if (user.purchased && user.purchased.plan.planId) properties.subscription = user.purchased.plan.planId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user