diff options
author | Bob Remeika <bob.remeika@gmail.com> | 2009-09-23 01:05:45 -0700 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:28 -0600 |
commit | c44682f6ab7f9b6dd3773752723aa8c46d019bde (patch) | |
tree | 8042494df1633857d7c8b38f81d6c270b2f6718b /actionpack/test | |
parent | a792ee5665fff4bd3751e97e1d949b60e73e333d (diff) | |
download | rails-c44682f6ab7f9b6dd3773752723aa8c46d019bde.tar.gz rails-c44682f6ab7f9b6dd3773752723aa8c46d019bde.tar.bz2 rails-c44682f6ab7f9b6dd3773752723aa8c46d019bde.zip |
Implemented a fuller stub in AjaxTestCase for url_for because link_to calls url_for on all urls passed to it. Tests that were testing different input types for the url were failing because of this.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/ajax_test.rb | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/actionpack/test/template/ajax_test.rb b/actionpack/test/template/ajax_test.rb index d212134d1d..afaa16874d 100644 --- a/actionpack/test/template/ajax_test.rb +++ b/actionpack/test/template/ajax_test.rb @@ -4,6 +4,17 @@ class AjaxTestCase < ActiveSupport::TestCase include ActionView::Helpers::AjaxHelper include ActionView::Helpers::TagHelper + def url_for(url) + case url + when Hash + "/url/hash" + when String + url + else + raise TypeError.new("Unsupported url type (#{url.class}) for this test helper") + end + end + def assert_html(html, matches) matches.each do |match| assert_match(Regexp.new(Regexp.escape(match)), html) @@ -23,26 +34,27 @@ class AjaxTestCase < ActiveSupport::TestCase end class LinkToRemoteTest < AjaxTestCase - def url_for(hash) - "/blog/destroy/4" - end - def link(options = {}) link_to_remote("Delete this post", "/blog/destroy/3", options) end - test "with no update" do - assert_html link, %w(href="/blog/destroy/4" Delete\ this\ post data-remote="true") - end - test "basic" do assert_html link(:update => "#posts"), %w(data-update-success="#posts") end + test "using a url string" do + assert_html link_to_remote("Test", "/blog/update/1"), + %w(href="/blog/update/1") + end + test "using a url hash" do link = link_to_remote("Delete this post", {:controller => :blog}, :update => "#posts") - assert_html link, %w(href="/blog/destroy/4" data-update-success="#posts") + assert_html link, %w(href="/url/hash" data-update-success="#posts") + end + + test "with no update" do + assert_html link, %w(href="/blog/destroy/4" Delete\ this\ post data-remote="true") end test "with :html options" do @@ -90,6 +102,7 @@ class ButtonToRemoteTest < AjaxTestCase button_to_remote("Remote outpost", options, html) end +<<<<<<< HEAD:actionpack/test/template/ajax_test.rb def url_for(*) "/whatnot" end @@ -101,6 +114,12 @@ class ButtonToRemoteTest < AjaxTestCase /data-url="\/whatnot"/].each do |match| assert_match(match, button) end +======= + class StandardTest < ButtonToRemoteTest + test "basic" do + assert_html button({:url => {:action => "whatnot"}}, {:class => "fine"}), + %w(input class="fine" type="button" value="Remote outpost" data-url="/url/hash") +>>>>>>> ea876bd... Implemented a fuller stub in AjaxTestCase for url_for because link_to calls url_for on all urls passed to it. Tests that were testing different input types for the url were failing because of this.:actionpack/test/javascript/ajax_test.rb end end |