From c907a4dd5027a740f2c79cb4babed2c258cbdf3f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 17 Jul 2013 17:30:54 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20"Loading=E2=80=A6"=20bug=20in=20task=20?= =?UTF-8?q?bar,=20added=20more=20tests.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/lib/app_post/task_manager.js.coffee | 28 ++++++--- test/browser/taskbar_task_test.rb | 59 ++++++++++++++++++- 2 files changed, 76 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index d623f3aba..fc1a5b7ed 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -66,7 +66,6 @@ class _taskManagerSingleton extends App.Controller super @workers = {} @workersStarted = {} - @taskUpdateProcess = {} @allTasks = [] @tasksToUpdate = {} @initialLoad = true @@ -77,14 +76,10 @@ class _taskManagerSingleton extends App.Controller App.Event.bind 'auth:login', => @initialLoad = true @all() + @tasksInitial() # render on logout App.Event.bind 'auth:logout', => - for task in @allTasks - worker = @worker( task.key ) - if worker && worker.release - worker.release() - delete @workersStarted[ task.key ] @reset() # send updates to server @@ -127,7 +122,8 @@ class _taskManagerSingleton extends App.Controller # create new task if not exists task = @get( key ) -# console.log('add', key, callback, params, to_not_show, task) + console.log('TASKBAR RESET', @allTasks) + console.log('add', key, callback, params, to_not_show, task) if !task task = new App.Taskbar task.load( @@ -279,8 +275,23 @@ class _taskManagerSingleton extends App.Controller @taskUpdate( task ) reset: => - @allTasks = [] + + # release tasks + for task in @allTasks + worker = @worker( task.key ) + if worker && worker.release + worker.release() + delete @workersStarted[ task.key ] + + # clear instance vars + @tasksToUpdate = {} + @allTasks = [] + @activeTask = undefined + + # clear inmem tasks App.Taskbar.deleteAll() + + # rerender task bar App.Event.trigger 'task:render' TaskbarId: => @@ -338,6 +349,7 @@ class _taskManagerSingleton extends App.Controller return tasksInitial: => + # reopen tasks App.Event.trigger 'taskbar:init' diff --git a/test/browser/taskbar_task_test.rb b/test/browser/taskbar_task_test.rb index 21b3817c6..b95bb5c8d 100644 --- a/test/browser/taskbar_task_test.rb +++ b/test/browser/taskbar_task_test.rb @@ -90,7 +90,7 @@ class TaskbarTaskTest < TestCase def test_persistant_task_with_relogin tests = [ { - :name => 'persistant task', + :name => 'agent1 - create persistant task', :action => [ { :execute => 'wait', @@ -137,7 +137,7 @@ class TaskbarTaskTest < TestCase :execute => 'wait', :value => 20, }, - { + { :execute => 'click', :css => 'a[href="#current_user"]', }, @@ -145,9 +145,57 @@ class TaskbarTaskTest < TestCase :execute => 'click', :css => 'a[href="#logout"]', }, + { + :execute => 'check', + :css => '#login', + :result => true, + }, { :execute => 'wait', - :value => 1, + :value => 10, + }, + ], + }, + { + :name => 'relogin with master - task are not viewable', + :action => [ + { + :execute => 'set', + :css => 'input[name="username"]', + :value => 'master@example.com', + }, + { + :execute => 'set', + :css => 'input[name="password"]', + :value => 'test' + }, + { + :execute => 'click', + :css => '#login button', + }, + { + :execute => 'wait', + :value => 6, + }, + { + :execute => 'match', + :css => 'body', + :value => 'INBOUND TEST#1', + :match_result => false, + }, + { + :execute => 'match', + :css => 'body', + :value => 'OUTBOUND TEST#1', + :match_result => false, + }, + { + :execute => 'click', + :css => 'a[href="#current_user"]', + }, + { + :execute => 'click', + :css => 'a[href="#logout"]', }, { :execute => 'check', @@ -166,6 +214,11 @@ class TaskbarTaskTest < TestCase :value => 'OUTBOUND TEST#1', :match_result => false, }, + ], + }, + { + :name => 'relogin with agent - task are viewable', + :action => [ { :execute => 'set', :css => 'input[name="username"]',