Permalink
Browse files

Update tests for ActiveSupport's JSON escaping change. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8034 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d5a93b6 commit d7aa32d5d04fc98730073523d429d9ce2547316a @technoweenie technoweenie committed Oct 26, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* Update tests for ActiveSupport's JSON escaping change. [rick]
+
* FormHelper's auto_index should use #to_param instead of #id_before_type_cast. Closes #9994 [mattly]
* Doc typo fixes for ActiveRecordHelper. Closes #9973 [mikong]
@@ -591,6 +591,7 @@ def response_from_page_or_rjs()
def unescape_rjs(rjs_string)
# RJS encodes double quotes and line breaks.
unescaped= rjs_string.gsub('\"', '"')
+ unescaped.gsub!(/\\\//, '/')
unescaped.gsub!('\n', "\n")
unescaped.gsub!('\076', '>')
unescaped.gsub!('\074', '<')
@@ -13,6 +13,9 @@ def id
def id_before_type_cast
123
end
+ def to_param
+ '123'
+ end
end
end
@@ -38,14 +38,14 @@ def test_link_to_function_with_rjs_block
html = link_to_function( "Greet me!" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
- assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074/h1\\076&quot;);; return false;">Greet me!</a>), html
+ assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074\\/h1\\076&quot;);; return false;">Greet me!</a>), html
end
def test_link_to_function_with_rjs_block_and_options
html = link_to_function( "Greet me!", :class => "updater" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
- assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074/h1\\076&quot;);; return false;">Greet me!</a>), html
+ assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074\\/h1\\076&quot;);; return false;">Greet me!</a>), html
end
def test_link_to_function_with_href
@@ -67,14 +67,14 @@ def test_button_to_function_with_rjs_block
html = button_to_function( "Greet me!" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
- assert_dom_equal %(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074/h1\\076&quot;);;" value="Greet me!" />), html
+ assert_dom_equal %(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074\\/h1\\076&quot;);;" value="Greet me!" />), html
end
def test_button_to_function_with_rjs_block_and_options
html = button_to_function( "Greet me!", :class => "greeter" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
- assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074/h1\\076&quot;);;" value="Greet me!" />), html
+ assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;\\074h1\\076Greetings\\074\\/h1\\076&quot;);;" value="Greet me!" />), html
end
def test_button_to_function_with_onclick
@@ -303,23 +303,23 @@ def setup
end
def test_insert_html_with_string
- assert_equal 'new Insertion.Top("element", "\\074p\\076This is a test\\074/p\\076");',
+ assert_equal 'new Insertion.Top("element", "\\074p\\076This is a test\\074\\/p\\076");',
@generator.insert_html(:top, 'element', '<p>This is a test</p>')
- assert_equal 'new Insertion.Bottom("element", "\\074p\076This is a test\\074/p\076");',
+ assert_equal 'new Insertion.Bottom("element", "\\074p\076This is a test\\074\\/p\076");',
@generator.insert_html(:bottom, 'element', '<p>This is a test</p>')
- assert_equal 'new Insertion.Before("element", "\\074p\076This is a test\\074/p\076");',
+ assert_equal 'new Insertion.Before("element", "\\074p\076This is a test\\074\\/p\076");',
@generator.insert_html(:before, 'element', '<p>This is a test</p>')
- assert_equal 'new Insertion.After("element", "\\074p\076This is a test\\074/p\076");',
+ assert_equal 'new Insertion.After("element", "\\074p\076This is a test\\074\\/p\076");',
@generator.insert_html(:after, 'element', '<p>This is a test</p>')
end
def test_replace_html_with_string
- assert_equal 'Element.update("element", "\\074p\\076This is a test\\074/p\\076");',
+ assert_equal 'Element.update("element", "\\074p\\076This is a test\\074\\/p\\076");',
@generator.replace_html('element', '<p>This is a test</p>')
end
def test_replace_element_with_string
- assert_equal 'Element.replace("element", "\\074div id=\"element\"\\076\\074p\\076This is a test\\074/p\\076\\074/div\\076");',
+ assert_equal 'Element.replace("element", "\\074div id=\"element\"\\076\\074p\\076This is a test\\074\\/p\\076\\074\\/div\\076");',
@generator.replace('element', '<div id="element"><p>This is a test</p></div>')
end
@@ -356,7 +356,7 @@ def test_alert
end
def test_redirect_to
- assert_equal 'window.location.href = "http://www.example.com/welcome";',
+ assert_equal 'window.location.href = "http:\\/\\/www.example.com\\/welcome";',
@generator.redirect_to(:action => 'welcome')
end
@@ -375,10 +375,10 @@ def test_to_s
@generator.replace_html('baz', '<p>This is a test</p>')
assert_equal <<-EOS.chomp, @generator.to_s
-new Insertion.Top("element", "\\074p\\076This is a test\\074/p\\076");
-new Insertion.Bottom("element", "\\074p\\076This is a test\\074/p\\076");
+new Insertion.Top("element", "\\074p\\076This is a test\\074\\/p\\076");
+new Insertion.Bottom("element", "\\074p\\076This is a test\\074\\/p\\076");
["foo", "bar"].each(Element.remove);
-Element.update("baz", "\\074p\\076This is a test\\074/p\\076");
+Element.update("baz", "\\074p\\076This is a test\\074\\/p\\076");
EOS
end

0 comments on commit d7aa32d

Please sign in to comment.