Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unescape_js to match changes in Action View #269

Merged
merged 1 commit into from Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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