Add user sync to sendAction

This commit is contained in:
Blade Barringer
2015-09-15 16:39:08 -05:00
parent 6aa04aa6fb
commit 78fe1073d4
2 changed files with 15 additions and 2 deletions

View File

@@ -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();
});
});
});

View File

@@ -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);
});;