mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #588 from sharelatex/sk-fix-project-feature-loading
Load user features alongside id and email.
This commit is contained in:
commit
f7073c4a3c
3 changed files with 93 additions and 1 deletions
|
@ -30,7 +30,14 @@ module.exports = CollaboratorsHandler =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
return callback null, members.map (m) -> m.id
|
return callback null, members.map (m) -> m.id
|
||||||
|
|
||||||
USER_PROJECTION: { _id: 1, email: 1 }
|
USER_PROJECTION: {
|
||||||
|
_id: 1,
|
||||||
|
email: 1,
|
||||||
|
features: 1,
|
||||||
|
first_name: 1,
|
||||||
|
last_name: 1,
|
||||||
|
signUpDate: 1
|
||||||
|
}
|
||||||
getMembersWithPrivilegeLevels: (project_id, callback = (error, members) ->) ->
|
getMembersWithPrivilegeLevels: (project_id, callback = (error, members) ->) ->
|
||||||
CollaboratorsHandler.getMemberIdsWithPrivilegeLevels project_id, (error, members = []) ->
|
CollaboratorsHandler.getMemberIdsWithPrivilegeLevels project_id, (error, members = []) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
expect = require("chai").expect
|
||||||
|
async = require("async")
|
||||||
|
User = require "./helpers/User"
|
||||||
|
request = require "./helpers/request"
|
||||||
|
settings = require "settings-sharelatex"
|
||||||
|
|
||||||
|
joinProject = (user_id, project_id, callback) ->
|
||||||
|
request.post {
|
||||||
|
url: "/project/#{project_id}/join"
|
||||||
|
qs: {user_id}
|
||||||
|
auth:
|
||||||
|
user: settings.apis.web.user
|
||||||
|
pass: settings.apis.web.pass
|
||||||
|
sendImmediately: true
|
||||||
|
json: true
|
||||||
|
jar: false
|
||||||
|
}, callback
|
||||||
|
|
||||||
|
describe "ProjectFeatures", ->
|
||||||
|
|
||||||
|
before (done) ->
|
||||||
|
@timeout(90000)
|
||||||
|
@owner = new User()
|
||||||
|
async.series [
|
||||||
|
(cb) => @owner.login cb
|
||||||
|
], done
|
||||||
|
|
||||||
|
describe "with private project", ->
|
||||||
|
before (done) ->
|
||||||
|
@owner.createProject "private-project", (error, project_id) =>
|
||||||
|
return done(error) if error?
|
||||||
|
@project_id = project_id
|
||||||
|
done()
|
||||||
|
|
||||||
|
describe "with an upgraded account", ->
|
||||||
|
before (done) ->
|
||||||
|
@owner.upgradeFeatures done
|
||||||
|
|
||||||
|
it "should have premium features", (done) ->
|
||||||
|
joinProject @owner._id, @project_id, (error, response, body) ->
|
||||||
|
expect(body.project.features.compileGroup).to.equal "priority"
|
||||||
|
expect(body.project.features.versioning).to.equal true
|
||||||
|
expect(body.project.features.templates).to.equal true
|
||||||
|
expect(body.project.features.dropbox).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
describe "with an basic account", ->
|
||||||
|
before (done) ->
|
||||||
|
@owner.downgradeFeatures done
|
||||||
|
|
||||||
|
it "should have basic features", (done) ->
|
||||||
|
joinProject @owner._id, @project_id, (error, response, body) ->
|
||||||
|
expect(body.project.features.compileGroup).to.equal "standard"
|
||||||
|
expect(body.project.features.versioning).to.equal false
|
||||||
|
expect(body.project.features.templates).to.equal false
|
||||||
|
expect(body.project.features.dropbox).to.equal false
|
||||||
|
done()
|
|
@ -51,6 +51,34 @@ class User
|
||||||
ensure_admin: (callback = (error) ->) ->
|
ensure_admin: (callback = (error) ->) ->
|
||||||
db.users.update {_id: ObjectId(@id)}, { $set: { isAdmin: true }}, callback
|
db.users.update {_id: ObjectId(@id)}, { $set: { isAdmin: true }}, callback
|
||||||
|
|
||||||
|
upgradeFeatures: (callback = (error) -> ) ->
|
||||||
|
features = {
|
||||||
|
collaborators: -1 # Infinite
|
||||||
|
versioning: true
|
||||||
|
dropbox:true
|
||||||
|
compileTimeout: 60
|
||||||
|
compileGroup:"priority"
|
||||||
|
templates: true
|
||||||
|
references: true
|
||||||
|
trackChanges: true
|
||||||
|
trackChangesVisible: true
|
||||||
|
}
|
||||||
|
db.users.update {_id: ObjectId(@id)}, { $set: { features: features }}, callback
|
||||||
|
|
||||||
|
downgradeFeatures: (callback = (error) -> ) ->
|
||||||
|
features = {
|
||||||
|
collaborators: 1
|
||||||
|
versioning: false
|
||||||
|
dropbox:false
|
||||||
|
compileTimeout: 60
|
||||||
|
compileGroup:"standard"
|
||||||
|
templates: false
|
||||||
|
references: false
|
||||||
|
trackChanges: false
|
||||||
|
trackChangesVisible: false
|
||||||
|
}
|
||||||
|
db.users.update {_id: ObjectId(@id)}, { $set: { features: features }}, callback
|
||||||
|
|
||||||
createProject: (name, callback = (error, project_id) ->) ->
|
createProject: (name, callback = (error, project_id) ->) ->
|
||||||
@request.post {
|
@request.post {
|
||||||
url: "/project/new",
|
url: "/project/new",
|
||||||
|
|
Loading…
Reference in a new issue