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 <cody@instructure.com>
Tested-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Brian Palmer 2012-03-03 09:08:00 -07:00
parent 33dbb5834a
commit 8fd44dce02
3 changed files with 23 additions and 11 deletions

View File

@ -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()

View File

@ -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.

View File

@ -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