Skip to content

Commit 8fd44dc

Browse files
committed
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>
1 parent 33dbb58 commit 8fd44dc

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

app/coffeescripts/jobs.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ define [
7777
return
7878
@loading[row] = true
7979
$.ajaxJSON @options.url, "GET", { flavor: @options.flavor, q: @query, offset: row }, (data) =>
80-
@data[row ... row + data.jobs.length] = data.jobs
80+
@data[row ... row + data[@type_name].length] = data[@type_name]
8181
@grid.invalidate()
8282
@$element.dequeue()
8383

spec/selenium/common.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ def setup_selenium
9999

100100
# f means "find" this is a shortcut to finding elements
101101
# if driver.find_element fails, then it'll try to find it with jquery
102-
def f(selector)
102+
def f(selector, scope = nil)
103103
begin
104-
driver.find_element :css, selector
104+
(scope || driver).find_element :css, selector
105105
rescue
106-
find_with_jquery selector
106+
find_with_jquery selector, scope
107107
end
108108
end
109109

110110
# same as `f` except tries to find several elements instead of one
111-
def ff(selector)
111+
def ff(selector, scope = nil)
112112
begin
113-
driver.find_elements :css, selector
113+
(scope || driver).find_elements :css, selector
114114
rescue
115-
find_all_with_jquery selector
115+
find_all_with_jquery selector, scope
116116
end
117117
end
118118

@@ -479,12 +479,12 @@ def keep_trying_until(seconds = SECONDS_UNTIL_GIVING_UP)
479479
val
480480
end
481481

482-
def find_with_jquery(selector)
483-
driver.execute_script("return $('#{selector.gsub(/'/, '\\\\\'')}')[0];")
482+
def find_with_jquery(selector, scope = nil)
483+
driver.execute_script("return $(arguments[0], arguments[1] && $(arguments[1]))[0];", selector, scope)
484484
end
485485

486-
def find_all_with_jquery(selector)
487-
driver.execute_script("return $('#{selector.gsub(/'/, '\\\\\'')}').toArray();")
486+
def find_all_with_jquery(selector, scope = nil)
487+
driver.execute_script("return $(arguments[0], arguments[1] && $(arguments[1])).toArray();", selector, scope)
488488
end
489489

490490
# pass in an Element pointing to the textarea that is tinified.

spec/selenium/jobs_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@
3434
Delayed::Job.count(:conditions => { :locked_by => 'on hold' }).should == 2
3535
end
3636
end
37+
38+
describe "running jobs" do
39+
it "should display running jobs in the workers grid" do
40+
j = Delayed::Job.last(:order => :id)
41+
j.lock_exclusively!(100, 'my test worker')
42+
get "/jobs"
43+
wait_for_ajax_requests
44+
ff('#running-grid .slick-row').size.should == 1
45+
row = f('#running-grid .slick-row')
46+
f('.l0', row).text.should == 'my test worker'
47+
end
48+
end
3749
end

0 commit comments

Comments
 (0)