From 7982e4e89099e01449a4207d029090ab76b2e7aa Mon Sep 17 00:00:00 2001 From: Tom Benner Date: Sun, 21 Jun 2015 11:33:32 -0700 Subject: [PATCH] Prevent redundant polling in the web UI --- test/test_web.rb | 6 ++++++ web/views/_nav.erb | 4 ++-- web/views/_poll_js.erb | 5 +++++ web/views/{_poll.erb => _poll_link.erb} | 3 --- web/views/layout.erb | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 web/views/_poll_js.erb rename web/views/{_poll.erb => _poll_link.erb} (81%) diff --git a/test/test_web.rb b/test/test_web.rb index 45045944..1eb14548 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -295,6 +295,12 @@ class TestWeb < Sidekiq::Test assert_match /#{msg['args'][2]}/, last_response.body end + it 'calls updatePage() once when polling' do + get '/busy?poll=true' + assert_equal 200, last_response.status + assert_equal 1, last_response.body.scan('updatePage(').count + end + it 'escape job args and error messages' do # on /retries page params = add_xss_retry diff --git a/web/views/_nav.erb b/web/views/_nav.erb index 8ddcd5fb..e7c3da1c 100644 --- a/web/views/_nav.erb +++ b/web/views/_nav.erb @@ -7,7 +7,7 @@ <%= erb :_footer %> + <%= erb :_poll_js %>