mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 21:23:45 -05:00
ObjectId query args
GitOrigin-RevId: 04e2258045c2cb4e2f93a24d842e67cb7996b5ce
This commit is contained in:
parent
d3a30929f7
commit
b335bcb67d
2 changed files with 31 additions and 39 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
const { ObjectId } = require('../../infrastructure/mongojs')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const { callbackify } = require('util')
|
const { callbackify } = require('util')
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('logger-sharelatex')
|
||||||
|
@ -126,7 +127,7 @@ async function getProjectUsersIds(projectId) {
|
||||||
// skip the first user id, which is always returned
|
// skip the first user id, which is always returned
|
||||||
const dropboxUsers = await UserGetter.getUsers(
|
const dropboxUsers = await UserGetter.getUsers(
|
||||||
{
|
{
|
||||||
_id: { $in: projectUserIds.slice(1) },
|
_id: { $in: projectUserIds.slice(1).map(id => ObjectId(id)) },
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const { ObjectId } = require('../../../../app/src/infrastructure/mongojs')
|
||||||
const SandboxedModule = require('sandboxed-module')
|
const SandboxedModule = require('sandboxed-module')
|
||||||
const chai = require('chai')
|
const chai = require('chai')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
@ -11,9 +12,9 @@ const modulePath = path.join(
|
||||||
)
|
)
|
||||||
|
|
||||||
const projectId = 'project_id_here'
|
const projectId = 'project_id_here'
|
||||||
const userId = 'user_id_here'
|
const userId = ObjectId()
|
||||||
const readOnlyRef = 'read_only_ref_1_id_here'
|
const readOnlyRef = ObjectId()
|
||||||
const collaberatorRef = 'collaberator_ref_1_here'
|
const collaberatorRef = ObjectId()
|
||||||
const projectName = 'project_name_here'
|
const projectName = 'project_name_here'
|
||||||
|
|
||||||
const thirdPartyDataStoreApiUrl = 'http://third-party-json-store.herokuapp.com'
|
const thirdPartyDataStoreApiUrl = 'http://third-party-json-store.herokuapp.com'
|
||||||
|
@ -131,21 +132,19 @@ describe('TpdsUpdateSender', function() {
|
||||||
job0.headers.sl_all_user_ids.should.equal(JSON.stringify([userId]))
|
job0.headers.sl_all_user_ids.should.equal(JSON.stringify([userId]))
|
||||||
|
|
||||||
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
||||||
group1.should.equal('collaberator_ref_1_here')
|
group1.should.equal(collaberatorRef)
|
||||||
job1.headers.sl_all_user_ids.should.equal(
|
job1.headers.sl_all_user_ids.should.equal(
|
||||||
JSON.stringify(['collaberator_ref_1_here'])
|
JSON.stringify([collaberatorRef])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
||||||
group2.should.equal('read_only_ref_1_id_here')
|
group2.should.equal(readOnlyRef)
|
||||||
job2.headers.sl_all_user_ids.should.equal(
|
job2.headers.sl_all_user_ids.should.equal(JSON.stringify([readOnlyRef]))
|
||||||
JSON.stringify(['read_only_ref_1_id_here'])
|
|
||||||
)
|
|
||||||
|
|
||||||
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
||||||
{
|
{
|
||||||
_id: {
|
_id: {
|
||||||
$in: ['collaberator_ref_1_here', 'read_only_ref_1_id_here']
|
$in: [collaberatorRef, readOnlyRef]
|
||||||
},
|
},
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
|
@ -185,21 +184,19 @@ describe('TpdsUpdateSender', function() {
|
||||||
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
||||||
|
|
||||||
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
||||||
group1.should.equal('collaberator_ref_1_here')
|
group1.should.equal(collaberatorRef)
|
||||||
job1.headers.sl_all_user_ids.should.equal(
|
job1.headers.sl_all_user_ids.should.equal(
|
||||||
JSON.stringify(['collaberator_ref_1_here'])
|
JSON.stringify([collaberatorRef])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
||||||
group2.should.equal('read_only_ref_1_id_here')
|
group2.should.equal(readOnlyRef)
|
||||||
job2.headers.sl_all_user_ids.should.equal(
|
job2.headers.sl_all_user_ids.should.equal(JSON.stringify([readOnlyRef]))
|
||||||
JSON.stringify(['read_only_ref_1_id_here'])
|
|
||||||
)
|
|
||||||
|
|
||||||
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
||||||
{
|
{
|
||||||
_id: {
|
_id: {
|
||||||
$in: ['collaberator_ref_1_here', 'read_only_ref_1_id_here']
|
$in: [collaberatorRef, readOnlyRef]
|
||||||
},
|
},
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
|
@ -232,21 +229,19 @@ describe('TpdsUpdateSender', function() {
|
||||||
job0.uri.should.equal(expectedUrl)
|
job0.uri.should.equal(expectedUrl)
|
||||||
|
|
||||||
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
||||||
group1.should.equal('collaberator_ref_1_here')
|
group1.should.equal(collaberatorRef)
|
||||||
job1.headers.sl_all_user_ids.should.equal(
|
job1.headers.sl_all_user_ids.should.equal(
|
||||||
JSON.stringify(['collaberator_ref_1_here'])
|
JSON.stringify([collaberatorRef])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
||||||
group2.should.equal('read_only_ref_1_id_here')
|
group2.should.equal(readOnlyRef)
|
||||||
job2.headers.sl_all_user_ids.should.equal(
|
job2.headers.sl_all_user_ids.should.equal(JSON.stringify([readOnlyRef]))
|
||||||
JSON.stringify(['read_only_ref_1_id_here'])
|
|
||||||
)
|
|
||||||
|
|
||||||
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
||||||
{
|
{
|
||||||
_id: {
|
_id: {
|
||||||
$in: ['collaberator_ref_1_here', 'read_only_ref_1_id_here']
|
$in: [collaberatorRef, readOnlyRef]
|
||||||
},
|
},
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
|
@ -282,21 +277,19 @@ describe('TpdsUpdateSender', function() {
|
||||||
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
||||||
|
|
||||||
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
||||||
group1.should.equal('collaberator_ref_1_here')
|
group1.should.equal(collaberatorRef)
|
||||||
job1.headers.sl_all_user_ids.should.equal(
|
job1.headers.sl_all_user_ids.should.equal(
|
||||||
JSON.stringify(['collaberator_ref_1_here'])
|
JSON.stringify([collaberatorRef])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
||||||
group2.should.equal('read_only_ref_1_id_here')
|
group2.should.equal(readOnlyRef)
|
||||||
job2.headers.sl_all_user_ids.should.equal(
|
job2.headers.sl_all_user_ids.should.equal(JSON.stringify([readOnlyRef]))
|
||||||
JSON.stringify(['read_only_ref_1_id_here'])
|
|
||||||
)
|
|
||||||
|
|
||||||
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
||||||
{
|
{
|
||||||
_id: {
|
_id: {
|
||||||
$in: ['collaberator_ref_1_here', 'read_only_ref_1_id_here']
|
$in: [collaberatorRef, readOnlyRef]
|
||||||
},
|
},
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
|
@ -331,21 +324,19 @@ describe('TpdsUpdateSender', function() {
|
||||||
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
job0.headers.sl_all_user_ids.should.eql(JSON.stringify([userId]))
|
||||||
|
|
||||||
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
const { group: group1, job: job1 } = this.request.secondCall.args[0].json
|
||||||
group1.should.equal('collaberator_ref_1_here')
|
group1.should.equal(collaberatorRef)
|
||||||
job1.headers.sl_all_user_ids.should.equal(
|
job1.headers.sl_all_user_ids.should.equal(
|
||||||
JSON.stringify(['collaberator_ref_1_here'])
|
JSON.stringify([collaberatorRef])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
const { group: group2, job: job2 } = this.request.thirdCall.args[0].json
|
||||||
group2.should.equal('read_only_ref_1_id_here')
|
group2.should.equal(readOnlyRef)
|
||||||
job2.headers.sl_all_user_ids.should.equal(
|
job2.headers.sl_all_user_ids.should.equal(JSON.stringify([readOnlyRef]))
|
||||||
JSON.stringify(['read_only_ref_1_id_here'])
|
|
||||||
)
|
|
||||||
|
|
||||||
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
|
||||||
{
|
{
|
||||||
_id: {
|
_id: {
|
||||||
$in: ['collaberator_ref_1_here', 'read_only_ref_1_id_here']
|
$in: [collaberatorRef, readOnlyRef]
|
||||||
},
|
},
|
||||||
'dropbox.access_token.uid': { $ne: null }
|
'dropbox.access_token.uid': { $ne: null }
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue