mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Ported groups service to user new api v3 and ported dependent controllers (#7108)
* Ported groups service to user new api v3 and ported dependent controllers * Remove and extra remove inviation code. Fixed group service caching and update group service tests * Fixed test logic and added party cache support * Added promise rejections and updated http interceptor
This commit is contained in:
committed by
Matteo Pagliazzi
parent
f2d5c921ed
commit
ea490c9a1f
@@ -23,6 +23,53 @@ describe('Groups Controller', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isMemberOfPendingQuest", function() {
|
||||
var party;
|
||||
var partyStub;
|
||||
|
||||
beforeEach(function () {
|
||||
party = specHelper.newGroup({
|
||||
_id: "unique-party-id",
|
||||
type: 'party',
|
||||
members: ['leader-id'] // Ensure we wouldn't pass automatically.
|
||||
});
|
||||
|
||||
partyStub = sandbox.stub(groups, "party", function() {
|
||||
return party;
|
||||
});
|
||||
});
|
||||
|
||||
it("returns false if group is does not have a quest", function() {
|
||||
expect(scope.isMemberOfPendingQuest(user._id, party)).to.not.be.ok;
|
||||
});
|
||||
|
||||
it("returns false if group quest has not members", function() {
|
||||
party.quest = {
|
||||
'key': 'random-key',
|
||||
};
|
||||
expect(scope.isMemberOfPendingQuest(user._id, party)).to.not.be.ok;
|
||||
});
|
||||
|
||||
it("returns false if group quest is active", function() {
|
||||
party.quest = {
|
||||
'key': 'random-key',
|
||||
'members': {},
|
||||
'active': true,
|
||||
};
|
||||
party.quest.members[user._id] = true;
|
||||
expect(scope.isMemberOfPendingQuest(user._id, party)).to.not.be.ok;
|
||||
});
|
||||
|
||||
it("returns true if user is a member of a pending quest", function() {
|
||||
party.quest = {
|
||||
'key': 'random-key',
|
||||
'members': {},
|
||||
};
|
||||
party.quest.members[user._id] = true;
|
||||
expect(scope.isMemberOfPendingQuest(user._id, party)).to.be.ok;
|
||||
});
|
||||
});
|
||||
|
||||
describe("isMemberOfGroup", function() {
|
||||
it("returns true if group is the user's party retrieved from groups service", function() {
|
||||
var party = specHelper.newGroup({
|
||||
@@ -31,7 +78,7 @@ describe('Groups Controller', function() {
|
||||
members: ['leader-id'] // Ensure we wouldn't pass automatically.
|
||||
});
|
||||
|
||||
var partyStub = sandbox.stub(groups,"party", function() {
|
||||
var partyStub = sandbox.stub(groups, "party", function() {
|
||||
return party;
|
||||
});
|
||||
|
||||
@@ -46,7 +93,7 @@ describe('Groups Controller', function() {
|
||||
members: [user._id]
|
||||
});
|
||||
|
||||
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
||||
var myGuilds = sandbox.stub(groups, "myGuilds", function() {
|
||||
return [guild];
|
||||
});
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
describe("Party Controller", function() {
|
||||
var scope, ctrl, user, User, questsService, groups, rootScope, $controller;
|
||||
var party;
|
||||
|
||||
beforeEach(function() {
|
||||
user = specHelper.newUser(),
|
||||
@@ -10,7 +11,13 @@ describe("Party Controller", function() {
|
||||
user: user,
|
||||
sync: sandbox.spy(),
|
||||
set: sandbox.spy()
|
||||
}
|
||||
};
|
||||
|
||||
party = specHelper.newGroup({
|
||||
_id: "unique-party-id",
|
||||
type: 'party',
|
||||
members: ['leader-id'] // Ensure we wouldn't pass automatically.
|
||||
});
|
||||
|
||||
module(function($provide) {
|
||||
$provide.value('User', User);
|
||||
@@ -136,6 +143,25 @@ describe("Party Controller", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("create", function() {
|
||||
var partyStub;
|
||||
|
||||
beforeEach(function () {
|
||||
partyStub = sandbox.stub(groups.Group, "create", function() {
|
||||
return party;
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a new party", function() {
|
||||
var group = {
|
||||
type: 'party',
|
||||
};
|
||||
scope.create(group);
|
||||
expect(partyStub).to.be.calledOnce;
|
||||
//@TODO: Check user party console.log(User.user.party.id)
|
||||
});
|
||||
});
|
||||
|
||||
describe('questAccept', function() {
|
||||
beforeEach(function() {
|
||||
scope.group = {
|
||||
|
||||
Reference in New Issue
Block a user