mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Add user sync to sendAction
This commit is contained in:
@@ -13,7 +13,7 @@ describe('Quests Service', function() {
|
|||||||
quest = {lvl:20};
|
quest = {lvl:20};
|
||||||
|
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
$provide.value('User', {user: user});
|
$provide.value('User', {sync: sinon.stub(), user: user});
|
||||||
});
|
});
|
||||||
|
|
||||||
inject(function(Quests, Groups, Content) {
|
inject(function(Quests, Groups, Content) {
|
||||||
@@ -364,7 +364,7 @@ describe('Quests Service', function() {
|
|||||||
expect(promise).to.respondTo('then');
|
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');
|
fakeBackend.expectPOST('/api/v2/groups/party-id/questReject');
|
||||||
|
|
||||||
questsService.sendAction('questReject')
|
questsService.sendAction('questReject')
|
||||||
@@ -376,5 +376,15 @@ describe('Quests Service', function() {
|
|||||||
fakeBackend.flush();
|
fakeBackend.flush();
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('syncs User', function() {
|
||||||
|
questsService.sendAction('questReject')
|
||||||
|
.then(function(res) {
|
||||||
|
expect(User.sync).to.be.calledOnce;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.$apply();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -121,10 +121,13 @@
|
|||||||
|
|
||||||
$http.post(ApiUrl.get() + '/api/v2/groups/' + party._id + '/' + action)
|
$http.post(ApiUrl.get() + '/api/v2/groups/' + party._id + '/' + action)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
User.sync();
|
||||||
|
|
||||||
Analytics.updateUser({
|
Analytics.updateUser({
|
||||||
partyID: party._id,
|
partyID: party._id,
|
||||||
partySize: party.memberCount
|
partySize: party.memberCount
|
||||||
});
|
});
|
||||||
|
|
||||||
var quest = response.data.quest;
|
var quest = response.data.quest;
|
||||||
resolve(quest);
|
resolve(quest);
|
||||||
});;
|
});;
|
||||||
|
|||||||
Reference in New Issue
Block a user