fix(task-queue): After restoring the queue at launch, start processing tasks

This commit is contained in:
Ben Gotow 2015-09-30 14:09:28 -07:00
parent 0818af0279
commit 174d4ecdc1
2 changed files with 14 additions and 0 deletions

View file

@ -1,4 +1,5 @@
Actions = require '../../src/flux/actions'
DatabaseStore = require '../../src/flux/stores/database-store'
TaskQueue = require '../../src/flux/stores/task-queue'
Task = require '../../src/flux/tasks/task'
@ -30,6 +31,18 @@ describe "TaskQueue", ->
# Flush any throttled or debounced updates
advanceClock(1000)
describe "restoreQueue", ->
it "should fetch the queue from the database, reset flags and start processing", ->
queue = [@processingTask, @unstartedTask]
spyOn(DatabaseStore, 'findJSONObject').andCallFake => Promise.resolve(queue)
spyOn(TaskQueue, '_processQueue')
waitsForPromise =>
TaskQueue._restoreQueue().then =>
expect(TaskQueue._queue).toEqual(queue)
expect(@processingTask.queueState.isProcessing).toEqual(false)
expect(TaskQueue._processQueue).toHaveBeenCalled()
describe "findTask", ->
beforeEach ->
@subclassA = new TaskSubclassA()

View file

@ -213,6 +213,7 @@ class TaskQueue
task.queueState ?= {}
task.queueState.isProcessing = false
@_queue = queue
@_processQueue()
_updateSoon: =>
@_updateSoonThrottled ?= _.throttle =>