From aab7d5c2572d58207916661e3d3efa7e928aa71d Mon Sep 17 00:00:00 2001 From: TheHollidayInn Date: Fri, 11 Sep 2015 12:56:19 -0500 Subject: [PATCH 1/4] Added test to check that group invites are removed when user cancels account --- test/api/users.coffee | 216 +++++++++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 79 deletions(-) diff --git a/test/api/users.coffee b/test/api/users.coffee index 772ad6eb9e..e465d1f3d5 100644 --- a/test/api/users.coffee +++ b/test/api/users.coffee @@ -31,103 +31,109 @@ describe "Users", -> ], done - it "Should choose a new group leader when deleting a user", (done) -> - userToDelete = undefined - userToBecomeLeader = undefined - guildToHaveNewLeader = undefined - async.waterfall [ - (cb) -> - registerManyUsers 2, cb + context "handle group changes when user cancels", -> + it "Should choose a new group leader when deleting a user", (done) -> + userToDelete = undefined + userToBecomeLeader = undefined + guildToHaveNewLeader = undefined + async.waterfall [ + (cb) -> + registerManyUsers 2, cb - (_users, cb) -> - userToDelete = _users[0] - userToBecomeLeader = _users[1] - User.findByIdAndUpdate userToDelete._id, - $set: - "balance": 4 - , (err, _user) -> + (_users, cb) -> + userToDelete = _users[0] + userToBecomeLeader = _users[1] + User.findByIdAndUpdate userToDelete._id, + $set: + "balance": 4 + , (err, _user) -> + cb() + + (cb) -> + request.post(baseURL + "/groups").send( + name: "GuildToGainNewLeader" + type: "guild" + ) + .set("X-API-User", userToDelete._id) + .set("X-API-Key", userToDelete.apiToken) + .end (res) -> + expectCode res, 200 + guildToHaveNewLeader = res.body + expect(guildToHaveNewLeader.leader).to.eql(userToDelete._id) cb() - (cb) -> - request.post(baseURL + "/groups").send( - name: "GuildToGainNewLeader" - type: "guild" - ) - .set("X-API-User", userToDelete._id) - .set("X-API-Key", userToDelete.apiToken) - .end (res) -> - expectCode res, 200 - guildToHaveNewLeader = res.body - expect(guildToHaveNewLeader.leader).to.eql(userToDelete._id) - cb() + (cb) -> + inviteURL = baseURL + "/groups/" + guildToHaveNewLeader._id + "/invite" + request.post(inviteURL) + .send( uuids: [userToBecomeLeader._id]) + .end (res) -> + expectCode res, 200 + cb() - (cb) -> - inviteURL = baseURL + "/groups/" + guildToHaveNewLeader._id + "/invite" - request.post(inviteURL) - .send( uuids: [userToBecomeLeader._id]) + (cb) -> + request.post(baseURL + "/groups/" + guildToHaveNewLeader._id + "/join") + .set("X-API-User", userToBecomeLeader._id) + .set("X-API-Key", userToBecomeLeader.apiToken) + .end (res) -> + expectCode res, 200 + cb() + + (cb) -> + request.del(baseURL + "/user") + .set("X-API-User", userToDelete._id) + .set("X-API-Key", userToDelete.apiToken) .end (res) -> expectCode res, 200 cb() - (cb) -> - request.post(baseURL + "/groups/" + guildToHaveNewLeader._id + "/join") + (cb) -> + request.get(baseURL + "/groups/" + guildToHaveNewLeader._id) .set("X-API-User", userToBecomeLeader._id) .set("X-API-Key", userToBecomeLeader.apiToken) .end (res) -> expectCode res, 200 + g = res.body + userInGroup = _.find(g.members, (member) -> return member._id == userToDelete._id; ) + expect(userInGroup).to.equal(undefined) + expect(g.leader._id).to.equal(userToBecomeLeader._id) cb() - (cb) -> - request.del(baseURL + "/user") - .set("X-API-User", userToDelete._id) - .set("X-API-Key", userToDelete.apiToken) - .end (res) -> - expectCode res, 200 - cb() + ], done - (cb) -> - request.get(baseURL + "/groups/" + guildToHaveNewLeader._id) - .set("X-API-User", userToBecomeLeader._id) - .set("X-API-Key", userToBecomeLeader.apiToken) - .end (res) -> - expectCode res, 200 - g = res.body - userInGroup = _.find(g.members, (member) -> return member._id == userToDelete._id; ) - expect(userInGroup).to.equal(undefined) - expect(g.leader._id).to.equal(userToBecomeLeader._id) - cb() + context "handle group and invite removals", -> + guild = undefined + party = undefined + before (done) -> + User.findByIdAndUpdate user._id, + $set: + "balance": 4 + , (err, _user) -> + async.waterfall [ + (cb) -> + request.post(baseURL + "/groups").send( + name: "TestPrivateGroup" + type: "party" + ) + .end (res) -> + expectCode res, 200 + party = res.body + cb() - ], done + (cb) -> + request.post(baseURL + "/groups").send( + name: "TestPrivateGroup" + type: "guild" + ) + .end (res) -> + expectCode res, 200 + guild = res.body + cb() - it 'Should remove a user from a group when deleting a user', (done) -> - userToDelete = undefined - guild = undefined - party = undefined - User.findByIdAndUpdate user._id, - $set: - "balance": 4 - , (err, _user) -> + ], done + + it 'Should remove a user from a group when deleting a user', (done) -> + userToDelete = undefined async.waterfall [ - (cb) -> - request.post(baseURL + "/groups").send( - name: "TestPrivateGroup" - type: "party" - ) - .end (res) -> - expectCode res, 200 - party = res.body - cb() - - (cb) -> - request.post(baseURL + "/groups").send( - name: "TestPrivateGroup" - type: "guild" - ) - .end (res) -> - expectCode res, 200 - guild = res.body - cb() - (cb) -> registerManyUsers 1, cb @@ -192,3 +198,55 @@ describe "Users", -> cb() ], done + + it 'Should remove invitations when deleting a user', (done) -> + userToDeleteInvites = undefined + async.waterfall [ + (cb) -> + registerManyUsers 1, cb + + # Send them invitations + (_users, cb) -> + userToDeleteInvites = _users[0] + inviteURL = baseURL + "/groups/" + party._id + "/invite" + request.post(inviteURL) + .send( uuids: [userToDeleteInvites._id]) + .end (res) -> + expectCode res, 200 + cb() + + (cb) -> + inviteURL = baseURL + "/groups/" + guild._id + "/invite" + request.post(inviteURL) + .send( uuids: [userToDeleteInvites._id]) + .end (res) -> + expectCode res, 200 + cb() + + (cb) -> + request.del(baseURL + "/user") + .set("X-API-User", userToDeleteInvites._id) + .set("X-API-Key", userToDeleteInvites.apiToken) + .end (res) -> + expectCode res, 200 + cb() + + (cb) -> + request.get(baseURL + "/groups/" + party._id) + .end (res) -> + expectCode res, 200 + g = res.body + userInviteForGroup = _.find(g.invites, (invite) -> return invite._id == userToDeleteInvites._id; ) + expect(userInviteForGroup).to.equal(undefined) + cb() + + (cb) -> + request.get(baseURL + "/groups/" + guild._id) + .end (res) -> + expectCode res, 200 + g = res.body + userInviteForGroup = _.find(g.invites, (invite) -> return invite._id == userToDeleteInvites._id; ) + expect(userInviteForGroup).to.equal(undefined) + cb() + + ], done From 7b4c50bdb7bb9acb9eb258c2bba1313e56fcae62 Mon Sep 17 00:00:00 2001 From: Alys Date: Sun, 27 Sep 2015 06:13:56 +1000 Subject: [PATCH 2/4] update locales edit/translate instructions --- common/locales/README.md | 11 ++++++++--- common/locales/en/_README_FIRST.md | 5 +++++ common/locales/zh/_README_FIRST.md | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 common/locales/en/_README_FIRST.md diff --git a/common/locales/README.md b/common/locales/README.md index 847262029f..e2b6e60d62 100644 --- a/common/locales/README.md +++ b/common/locales/README.md @@ -4,7 +4,12 @@ The files in this folder are automatically pulled from Transifex, with exception of the original American-English strings which are managed directly through GitHub in `locales/en`. -Do not edit files in any locales directory except for `locales/en`! +When you need to change any text, edit only the files in `locales/en`. +Do not edit files in any other locales directory. You do not need to +request that your changes be translated; changes are automatically +copied to Transifex on a regular basis. -Before starting to translate, please read [Guidance for Linguists](http://habitrpg.wikia.com/wiki/Guidance_for_Linguists) -and note especially its information about the [Translations Trello card](https://trello.com/c/SvTsLdRF/12-translations). +If you want to help with translations, please first read [Guidance for +Linguists](http://habitrpg.wikia.com/wiki/Guidance_for_Linguists) and +note especially its information about the [Translations Trello +card](https://trello.com/c/SvTsLdRF/12-translations). diff --git a/common/locales/en/_README_FIRST.md b/common/locales/en/_README_FIRST.md new file mode 100644 index 0000000000..20d13f4e79 --- /dev/null +++ b/common/locales/en/_README_FIRST.md @@ -0,0 +1,5 @@ +Do not edit any files in this directory! + +For more information read: + +https://github.com/HabitRPG/habitrpg/blob/develop/common/locales/README.md diff --git a/common/locales/zh/_README_FIRST.md b/common/locales/zh/_README_FIRST.md index 20d13f4e79..2249f259bc 100644 --- a/common/locales/zh/_README_FIRST.md +++ b/common/locales/zh/_README_FIRST.md @@ -1,4 +1,5 @@ -Do not edit any files in this directory! +You may edit any files in this directory. Do not edit files in any +other locales directory. For more information read: From 6902d9aa2fc3a3638132489644b1bca33c333c82 Mon Sep 17 00:00:00 2001 From: Alys Date: Sun, 27 Sep 2015 06:52:23 +1000 Subject: [PATCH 3/4] swap README files for en and zk. What WAS I thinking? --- common/locales/en/_README_FIRST.md | 3 ++- common/locales/zh/_README_FIRST.md | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/locales/en/_README_FIRST.md b/common/locales/en/_README_FIRST.md index 20d13f4e79..2249f259bc 100644 --- a/common/locales/en/_README_FIRST.md +++ b/common/locales/en/_README_FIRST.md @@ -1,4 +1,5 @@ -Do not edit any files in this directory! +You may edit any files in this directory. Do not edit files in any +other locales directory. For more information read: diff --git a/common/locales/zh/_README_FIRST.md b/common/locales/zh/_README_FIRST.md index 2249f259bc..20d13f4e79 100644 --- a/common/locales/zh/_README_FIRST.md +++ b/common/locales/zh/_README_FIRST.md @@ -1,5 +1,4 @@ -You may edit any files in this directory. Do not edit files in any -other locales directory. +Do not edit any files in this directory! For more information read: From 1616b237fac93a3d7f7225a51bc2537ce5024020 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 27 Sep 2015 22:54:01 -0500 Subject: [PATCH 4/4] Revert npm bin commit Vagrant installs don't use the .bin directory because Virtualbox has issues with symlinks see https://github.com/HabitRPG/habitrpg/issues/4591#issuecomment-72344790 --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a4e9cbaaef..63904f57e1 100644 --- a/package.json +++ b/package.json @@ -87,11 +87,11 @@ "node": "0.10.x" }, "scripts": { - "test": "$(npm bin)/gulp test", - "start": "$(npm bin)/gulp run:dev", - "sprites": "$(npm bin)/gulp sprites:compile", - "postinstall": "$(npm bin)/bower --config.interactive=false install -f; $(npm bin)/gulp build;", - "coverage": "COVERAGE=true $(npm bin)/mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html" + "test": "gulp test", + "start": "gulp run:dev", + "sprites": "gulp sprites:compile", + "postinstall": "bower --config.interactive=false install -f; gulp build;", + "coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html" }, "devDependencies": { "chai": "^2.3.0",