vendor/rails/actionpack/test/template/url_helper_test.rb in radiant-0.6.9 vs vendor/rails/actionpack/test/template/url_helper_test.rb in radiant-0.7.0
- old
+ new
@@ -1,13 +1,11 @@
-require "#{File.dirname(__FILE__)}/../abstract_unit"
+require 'abstract_unit'
RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env)
-class UrlHelperTest < Test::Unit::TestCase
- include ActionView::Helpers::AssetTagHelper
- include ActionView::Helpers::UrlHelper
- include ActionView::Helpers::TagHelper
+class UrlHelperTest < ActionView::TestCase
+ tests ActionView::Helpers::UrlHelper
def setup
@controller = Class.new do
attr_accessor :url, :request
def url_for(options)
@@ -284,18 +282,19 @@
assert_dom_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)")
assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain.com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)")
assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)")
assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain(dot)com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)")
assert_dom_equal "<script type=\"text/javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
+ assert_dom_equal "<script type=\"text/javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", nil, :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
end
def protect_against_forgery?
false
end
end
-class UrlHelperWithControllerTest < Test::Unit::TestCase
+class UrlHelperWithControllerTest < ActionView::TestCase
class UrlHelperController < ActionController::Base
self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
def self.controller_path; 'url_helper_with_controller' end
@@ -305,14 +304,18 @@
def show_named_route
render :inline => "<%= show_named_route_#{params[:kind]} %>"
end
+ def nil_url_for
+ render :inline => '<%= url_for(nil) %>'
+ end
+
def rescue_action(e) raise e end
end
- include ActionView::Helpers::UrlHelper
+ tests ActionView::Helpers::UrlHelper
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@controller = UrlHelperController.new
@@ -321,11 +324,11 @@
def test_url_for_shows_only_path
get :show_url_for
assert_equal '/url_helper_with_controller/show_url_for', @response.body
end
- def test_named_route_shows_host_and_path
+ def test_named_route_url_shows_host_and_path
with_url_helper_routing do
get :show_named_route, :kind => 'url'
assert_equal 'http://test.host/url_helper_with_controller/show_named_route', @response.body
end
end
@@ -335,10 +338,15 @@
get :show_named_route, :kind => 'path'
assert_equal '/url_helper_with_controller/show_named_route', @response.body
end
end
+ def test_url_for_nil_returns_current_path
+ get :nil_url_for
+ assert_equal '/url_helper_with_controller/nil_url_for', @response.body
+ end
+
protected
def with_url_helper_routing
with_routing do |set|
set.draw do |map|
map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route'
@@ -346,11 +354,11 @@
yield
end
end
end
-class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
+class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
class TasksController < ActionController::Base
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
def self.controller_path; 'tasks' end
@@ -370,11 +378,11 @@
"<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" +
"<%= link_to_unless_current(\"tasks\", tasks_url) %>"
end
end
- include ActionView::Helpers::UrlHelper
+ tests ActionView::Helpers::UrlHelper
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@controller = TasksController.new
@@ -438,11 +446,11 @@
def to_s
id.to_s
end
end
-class PolymorphicControllerTest < Test::Unit::TestCase
+class PolymorphicControllerTest < ActionView::TestCase
class WorkshopsController < ActionController::Base
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
def self.controller_path; 'workshops' end
@@ -477,10 +485,10 @@
end
def rescue_action(e) raise e end
end
- include ActionView::Helpers::UrlHelper
+ tests ActionView::Helpers::UrlHelper
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end