diff --git a/test/spec/services/questServicesSpec.js b/test/spec/services/questServicesSpec.js index c9f3e05c21..e7f8c638b2 100644 --- a/test/spec/services/questServicesSpec.js +++ b/test/spec/services/questServicesSpec.js @@ -13,7 +13,7 @@ describe('Quests Service', function() { quest = {lvl:20}; module(function($provide) { - $provide.value('User', {user: user}); + $provide.value('User', {sync: sinon.stub(), user: user}); }); inject(function(Quests, Groups, Content) { @@ -364,7 +364,7 @@ describe('Quests Service', function() { expect(promise).to.respondTo('then'); }); - it('calls specified endpoint endpoint', function(done) { + it('calls specified quest endpoint', function(done) { fakeBackend.expectPOST('/api/v2/groups/party-id/questReject'); questsService.sendAction('questReject') @@ -376,5 +376,15 @@ describe('Quests Service', function() { fakeBackend.flush(); scope.$apply(); }); + + it('syncs User', function() { + questsService.sendAction('questReject') + .then(function(res) { + expect(User.sync).to.be.calledOnce; + done(); + }); + + scope.$apply(); + }); }); }); diff --git a/website/public/js/services/questServices.js b/website/public/js/services/questServices.js index 3662fd1b35..a69ae800d8 100644 --- a/website/public/js/services/questServices.js +++ b/website/public/js/services/questServices.js @@ -121,10 +121,13 @@ $http.post(ApiUrl.get() + '/api/v2/groups/' + party._id + '/' + action) .then(function(response) { + User.sync(); + Analytics.updateUser({ partyID: party._id, partySize: party.memberCount }); + var quest = response.data.quest; resolve(quest); });;