fix(sync): Do not paginate /metadata unless pluginsSupported

This commit is contained in:
Ben Gotow 2016-03-10 16:03:32 -08:00
parent 963d1d92cb
commit a24f67398e
2 changed files with 14 additions and 1 deletions

View file

@ -139,7 +139,10 @@ class NylasSyncWorker
console.log("Retrieved #{offset + data.length} metadata objects")
finished()
makeMetadataRequest(0)
if @_api.pluginsSupported
makeMetadataRequest(0)
else
finished()
shouldFetchCollection: (model) ->
return false unless @_state

View file

@ -7,6 +7,7 @@ describe "NylasSyncWorker", ->
beforeEach ->
@apiRequests = []
@api =
pluginsSupported: true
accessTokenForAccountId: =>
'123'
makeRequest: (requestOptions) =>
@ -192,6 +193,15 @@ describe "NylasSyncWorker", ->
fetchAllMetadataCallback()
expect(@worker.fetchCollection.calls.length).not.toBe(0)
it "should not fetch metadata pages if pluginsSupported is false", ->
@api.pluginsSupported = false
spyOn(NylasSyncWorker.prototype, '_fetchWithErrorHandling')
spyOn(@worker, 'fetchCollection')
@worker._state = {}
@worker.resumeFetches()
expect(@worker._fetchWithErrorHandling).not.toHaveBeenCalled()
expect(@worker.fetchCollection.calls.length).not.toBe(0)
it "should fetch collections for which `shouldFetchCollection` returns true", ->
spyOn(@worker, 'fetchCollection')
spyOn(@worker, 'shouldFetchCollection').andCallFake (collection) =>