Fix unescape_js to match changes in Action View

Unescapes dollar signs and backticks added by rails/rails@033a738817
This commit is contained in:
Roque Pinel
2020-03-30 16:42:09 -04:00
parent 755314276c
commit b6d6e25148
2 changed files with 8 additions and 0 deletions

View File

@@ -124,6 +124,8 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
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

View File

@@ -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
@@ -43,6 +45,10 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
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