diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 14:06:33 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 14:06:33 +0000 |
commit | fd9967bca2aa32dd4173881c4d8c55f5ebabe97e (patch) | |
tree | 06d7e2a012800e33dbbfbf69ccee0d621f08d8df /actionpack/test/template/url_helper_test.rb | |
parent | 9eb04967a4b7b7382cf5c562d379fdd65ceaaf1b (diff) | |
download | rails-fd9967bca2aa32dd4173881c4d8c55f5ebabe97e.tar.gz rails-fd9967bca2aa32dd4173881c4d8c55f5ebabe97e.tar.bz2 rails-fd9967bca2aa32dd4173881c4d8c55f5ebabe97e.zip |
Added UrlHelper#link_to_if/link_to_unless to enable other conditions that just link_to_unless_current #757 [mindel]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@852 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/url_helper_test.rb')
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 98686c5f15..19c8e825d6 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -50,6 +50,28 @@ class UrlHelperTest < Test::Unit::TestCase link_image_to("rss.gif", "http://www.example.com", :size => "30x45", :alt => "Feed", :class => "admin") end + def test_link_to_unless + assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog") + assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog") + assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) + assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name, options, html_options, *parameters_for_method_reference| + "<strong>#{name}</strong>" + } + assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name| + "<strong>#{name}</strong>" + } + assert_equal "test", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { + "test" + } + end + + def test_link_to_if + assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog") + assert "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog") + assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1) + end + + def test_link_unless_current @request = RequestMock.new("http://www.example.com") assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog") |