Skip to content

Commit

Permalink
Remove poll_js and inline JS script, fixes #3133
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Sep 12, 2016
1 parent 1c05404 commit 0c09878
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
8 changes: 8 additions & 0 deletions lib/sidekiq/web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def display_custom_head
@head_html.join if defined?(@head_html)
end

def poll_path
if current_path != '' && params['poll']
root_path + current_path
else
""
end
end

# Given a browser request Accept-Language header like
# "fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2", this function
# will return "fr" since that's the first code with a matching
Expand Down
2 changes: 1 addition & 1 deletion test/test_web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def perform(a, b)
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
assert_equal 1, last_response.body.scan('data-poll-path="/busy').count
end

it 'escape job args and error messages' do
Expand Down
5 changes: 5 additions & 0 deletions web/assets/javascripts/application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions web/views/_poll_js.erb

This file was deleted.

3 changes: 1 addition & 2 deletions web/views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<meta name="google" content="notranslate" />
<%= display_custom_head %>
</head>
<body class="admin">
<body class="admin" data-poll-path="<%= poll_path %>">
<%= erb :_nav %>
<div id="page">
<div class="container">
Expand All @@ -28,6 +28,5 @@
</div>
</div>
<%= erb :_footer %>
<%= erb :_poll_js %>
</body>
</html>

0 comments on commit 0c09878

Please sign in to comment.