Skip to content

Commit

Permalink
Merge pull request #269 from repinel/fix-unescape-js
Browse files Browse the repository at this point in the history
Fix `unescape_js` to match changes in Action View
  • Loading branch information
kaspth committed Mar 30, 2020
2 parents 7553142 + b6d6e25 commit 6361d43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/jquery/assert_select.rb
Expand Up @@ -124,6 +124,8 @@ def unescape_js(js_string)
unescaped.gsub!('\n', "\n")
unescaped.gsub!('\076', '>')
unescaped.gsub!('\074', '<')
unescaped.gsub!(/\\\$/, '$')
unescaped.gsub!(/\\`/, '`')
# js encodes non-ascii characters.
unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
unescaped
Expand Down
6 changes: 6 additions & 0 deletions test/assert_select_jquery_test.rb
Expand Up @@ -23,6 +23,8 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
// without semicolon
$("#browser_cart").hide("blind", 1000)
$('#item').html('<div><span>\\`Total\\`: \\$12.34</span></div>');
JS

setup do
Expand All @@ -43,6 +45,10 @@ def test_target_as_receiver
assert_select_jquery :remove, "#cart tr:not(.total_line) > *"
assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]"
assert_select_jquery :remove, "tr + td, li"

assert_select_jquery :html, '#item' do
assert_select 'span', '`Total`: $12.34'
end
end

assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do
Expand Down

0 comments on commit 6361d43

Please sign in to comment.