Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7904: prototype_helper_test.with_degradation.diff

File prototype_helper_test.with_degradation.diff, 4.5 kB (added by chuyeow, 1 year ago)

Diff that includes tests for the patch to link_to_remote in prototype_helper.rb

  • prototype_helper_test.rb

    old new  
    4040  include BaseTest 
    4141   
    4242  def test_link_to_remote 
    43     assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>), 
     43    assert_dom_equal %(<a class=\"fine\" href=\"http://www.example.com/whatnot\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>), 
    4444      link_to_remote("Remote outpost", { :url => { :action => "whatnot"  }}, { :class => "fine"  }) 
    45     assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
     45    assert_dom_equal %(<a href=\"http://www.example.com/whatnot\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
    4646      link_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot"  })       
    47     assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
     47    assert_dom_equal %(<a href=\"http://www.example.com/whatnot\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
    4848      link_to_remote("Remote outpost", :success => "alert(request.reponseText)", :url => { :action => "whatnot"  }) 
    49     assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
     49    assert_dom_equal %(<a href=\"http://www.example.com/whatnot\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
    5050      link_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot"  }) 
    51     assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
     51    assert_dom_equal %(<a href=\"http://www.example.com/whatnot?a=10&amp;b=20\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>), 
    5252      link_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) 
    5353  end 
    5454   
     55  def test_link_to_remote_with_href_wont_attempt_degradation 
     56    assert_dom_equal %(<a href=\"http://www.example.com/fallback\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>), 
     57      link_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :href => "http://www.example.com/fallback" }) 
     58    assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>), 
     59      link_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :href => "#" }) 
     60    assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>), 
     61      link_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :href => nil }) 
     62  end 
     63   
    5564  def test_periodically_call_remote 
    5665    assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>), 
    5766      periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" })