Begin work on indexing the references when project is opened.
This commit is contained in:
@@ -46,6 +46,8 @@ describe "ProjectController", ->
|
||||
reactivateProjectIfRequired:sinon.stub()
|
||||
@ProjectUpdateHandler =
|
||||
markAsOpened: sinon.stub()
|
||||
@ReferencesSearchHandler =
|
||||
indexProjectReferences: sinon.stub()
|
||||
@ProjectController = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex":@settings
|
||||
"logger-sharelatex":
|
||||
@@ -63,6 +65,7 @@ describe "ProjectController", ->
|
||||
"../../managers/SecurityManager":@SecurityManager
|
||||
"../InactiveData/InactiveProjectManager":@InactiveProjectManager
|
||||
"./ProjectUpdateHandler":@ProjectUpdateHandler
|
||||
"../ReferencesSearch/ReferencesSearchHandler": @ReferencesSearchHandler
|
||||
|
||||
@user =
|
||||
_id:"!£123213kjljkl"
|
||||
|
||||
+2
-4
@@ -110,9 +110,8 @@ describe "ReferencesSearchController", ->
|
||||
it 'should call ReferencesSearchHandler.indexFile', (done) ->
|
||||
@res.send = (status) =>
|
||||
@ReferencesSearchHandler.indexFile.calledOnce.should.equal true
|
||||
expected_url = "http://some.url/project/2222/doc/3333"
|
||||
@ReferencesSearchHandler.indexFile
|
||||
.calledWith(@project_id, expected_url).should.equal true
|
||||
.calledWith(@project_id, @doc_id).should.equal true
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
@@ -162,9 +161,8 @@ describe "ReferencesSearchController", ->
|
||||
it 'should call ReferencesSearchHandler.indexFile', (done) ->
|
||||
@res.send = (status) =>
|
||||
@ReferencesSearchHandler.indexFile.calledOnce.should.equal true
|
||||
expected_url = "http://some.url/project/2222/doc/3333"
|
||||
@ReferencesSearchHandler.indexFile
|
||||
.calledWith(@project_id, expected_url).should.equal true
|
||||
.calledWith(@project_id, @doc_id).should.equal true
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
|
||||
+6
-4
@@ -9,14 +9,16 @@ describe 'ReferencesSearchHandler', ->
|
||||
|
||||
beforeEach ->
|
||||
@project_id = '222'
|
||||
@file_url = 'http://example.com/some/file'
|
||||
@file_id = '111111'
|
||||
@handler = SandboxedModule.require modulePath, requires:
|
||||
'logger-sharelatex': {
|
||||
log: ->
|
||||
err: ->
|
||||
}
|
||||
'settings-sharelatex': @settings = {
|
||||
apis: {references: {url: 'http://some.url'}}
|
||||
apis:
|
||||
references: {url: 'http://some.url'}
|
||||
web: {url: 'http://some.url'}
|
||||
}
|
||||
'request': @request = {
|
||||
get: sinon.stub()
|
||||
@@ -30,7 +32,7 @@ describe 'ReferencesSearchHandler', ->
|
||||
@request.post.callsArgWith(1, null, {statusCode: 201}, {})
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@handler.indexFile @project_id, @file_url, (err) =>
|
||||
@handler.indexFile @project_id, @file_id, (err) =>
|
||||
expect(err).to.equal null
|
||||
done()
|
||||
|
||||
@@ -39,7 +41,7 @@ describe 'ReferencesSearchHandler', ->
|
||||
@request.post.callsArgWith(1, null, {statusCode: 500}, {})
|
||||
|
||||
it 'should produce an error', (done) ->
|
||||
@handler.indexFile @project_id, @file_url, (err) =>
|
||||
@handler.indexFile @project_id, @file_id, (err) =>
|
||||
expect(err).to.not.equal null
|
||||
done()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user