From 8fd44dce02ee66e08deb6f6a83276aae46daef27 Mon Sep 17 00:00:00 2001 From: Brian Palmer Date: Sat, 3 Mar 2012 09:08:00 -0700 Subject: [PATCH] fix displaying of running jobs test plan: have a job running, visit /jobs, ensure it's displayed correctly Change-Id: I2b96155f147c08aceef0168abd87a0526773b4b4 Reviewed-on: https://gerrit.instructure.com/9165 Reviewed-by: Cody Cutrer Tested-by: Brian Palmer --- app/coffeescripts/jobs.coffee | 2 +- spec/selenium/common.rb | 20 ++++++++++---------- spec/selenium/jobs_spec.rb | 12 ++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/coffeescripts/jobs.coffee b/app/coffeescripts/jobs.coffee index 652dc6b4f77..b9c12ae2726 100644 --- a/app/coffeescripts/jobs.coffee +++ b/app/coffeescripts/jobs.coffee @@ -77,7 +77,7 @@ define [ return @loading[row] = true $.ajaxJSON @options.url, "GET", { flavor: @options.flavor, q: @query, offset: row }, (data) => - @data[row ... row + data.jobs.length] = data.jobs + @data[row ... row + data[@type_name].length] = data[@type_name] @grid.invalidate() @$element.dequeue() diff --git a/spec/selenium/common.rb b/spec/selenium/common.rb index 479fd18a3af..6c9cb7d29e1 100644 --- a/spec/selenium/common.rb +++ b/spec/selenium/common.rb @@ -99,20 +99,20 @@ module SeleniumTestsHelperMethods # f means "find" this is a shortcut to finding elements # if driver.find_element fails, then it'll try to find it with jquery - def f(selector) + def f(selector, scope = nil) begin - driver.find_element :css, selector + (scope || driver).find_element :css, selector rescue - find_with_jquery selector + find_with_jquery selector, scope end end # same as `f` except tries to find several elements instead of one - def ff(selector) + def ff(selector, scope = nil) begin - driver.find_elements :css, selector + (scope || driver).find_elements :css, selector rescue - find_all_with_jquery selector + find_all_with_jquery selector, scope end end @@ -479,12 +479,12 @@ shared_examples_for "all selenium tests" do val end - def find_with_jquery(selector) - driver.execute_script("return $('#{selector.gsub(/'/, '\\\\\'')}')[0];") + def find_with_jquery(selector, scope = nil) + driver.execute_script("return $(arguments[0], arguments[1] && $(arguments[1]))[0];", selector, scope) end - def find_all_with_jquery(selector) - driver.execute_script("return $('#{selector.gsub(/'/, '\\\\\'')}').toArray();") + def find_all_with_jquery(selector, scope = nil) + driver.execute_script("return $(arguments[0], arguments[1] && $(arguments[1])).toArray();", selector, scope) end # pass in an Element pointing to the textarea that is tinified. diff --git a/spec/selenium/jobs_spec.rb b/spec/selenium/jobs_spec.rb index 44cd953ad90..272cee14fe9 100644 --- a/spec/selenium/jobs_spec.rb +++ b/spec/selenium/jobs_spec.rb @@ -34,4 +34,16 @@ describe "jobs ui" do Delayed::Job.count(:conditions => { :locked_by => 'on hold' }).should == 2 end end + + describe "running jobs" do + it "should display running jobs in the workers grid" do + j = Delayed::Job.last(:order => :id) + j.lock_exclusively!(100, 'my test worker') + get "/jobs" + wait_for_ajax_requests + ff('#running-grid .slick-row').size.should == 1 + row = f('#running-grid .slick-row') + f('.l0', row).text.should == 'my test worker' + end + end end