diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/log_subscriber_test.rb | 19 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/dispatch/mapper_test.rb | 7 | ||||
-rw-r--r-- | actionpack/test/dispatch/prefix_generation_test.rb | 12 | ||||
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 20 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/_200.html.erb | 1 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 80 | ||||
-rw-r--r-- | actionpack/test/template/test_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 8 |
12 files changed, 136 insertions, 48 deletions
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 80c4fa2ee5..ccdfcb0b2c 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -6,6 +6,13 @@ module Another class LogSubscribersController < ActionController::Base wrap_parameters :person, :include => :name, :format => :json + class SpecialException < Exception + end + + rescue_from SpecialException do + head :status => 406 + end + def show render :nothing => true end @@ -39,6 +46,10 @@ module Another raise Exception end + def with_rescued_exception + raise SpecialException + end + end end @@ -195,6 +206,14 @@ class ACLogSubscriberTest < ActionController::TestCase assert_match(/Completed 500/, logs.last) end + def test_process_action_with_rescued_exception_includes_http_status_code + get :with_rescued_exception + wait + + assert_equal 2, logs.size + assert_match(/Completed 406/, logs.last) + end + def logs @logs ||= @logger.logged(:info) end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index be59da9105..ce4b407c7d 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -14,6 +14,14 @@ module Fun end end +module Quiz + class QuestionsController < ActionController::Base + def new + render :partial => Quiz::Question.new("Namespaced Partial") + end + end +end + class TestController < ActionController::Base protect_from_forgery @@ -1251,6 +1259,12 @@ class RenderTest < ActionController::TestCase assert_template('fun/games/_form') end + def test_namespaced_object_partial + @controller = Quiz::QuestionsController.new + get :new + assert_equal "Namespaced Partial", @response.body + end + def test_partial_collection get :partial_collection assert_equal "Hello: davidHello: mary", @response.body diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index b6c08ffc33..81f0efb76e 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -83,6 +83,13 @@ module ActionDispatch assert_equal '/*path', fakeset.conditions.first[:path_info] assert_nil fakeset.requirements.first[:path] end + + def test_map_wildcard_with_format_true + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/*path', :to => 'pages#show', :format => true + assert_equal '/*path.:format', fakeset.conditions.first[:path_info] + end end end end diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb index b28a058250..93eccaecbd 100644 --- a/actionpack/test/dispatch/prefix_generation_test.rb +++ b/actionpack/test/dispatch/prefix_generation_test.rb @@ -50,7 +50,9 @@ module TestGenerationPrefix scope "/:omg", :omg => "awesome" do mount BlogEngine => "/blog", :as => "blog_engine" end + match "/posts/:id", :to => "outside_engine_generating#post", :as => :post match "/generate", :to => "outside_engine_generating#index" + match "/polymorphic_path_for_app", :to => "outside_engine_generating#polymorphic_path_for_app" match "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine" match "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for" match "/conflicting_url", :to => "outside_engine_generating#conflicting" @@ -101,6 +103,7 @@ module TestGenerationPrefix class ::OutsideEngineGeneratingController < ActionController::Base include BlogEngine.routes.mounted_helpers + include RailsApplication.routes.url_helpers def index render :text => blog_engine.post_path(:id => 1) @@ -110,6 +113,10 @@ module TestGenerationPrefix render :text => blog_engine.polymorphic_path(Post.new) end + def polymorphic_path_for_app + render :text => polymorphic_path(Post.new) + end + def polymorphic_with_url_for render :text => blog_engine.url_for(Post.new) end @@ -201,6 +208,11 @@ module TestGenerationPrefix assert_equal "/awesome/blog/posts/1", last_response.body end + test "polymorphic_path_for_app" do + get "/polymorphic_path_for_app" + assert_equal "/posts/1", last_response.body + end + test "[APP] generating engine's url with url_for(@post)" do get "/polymorphic_with_url_for" assert_equal "http://example.org/awesome/blog/posts/1", last_response.body diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 25b1b4f745..060bcfb5ec 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -468,6 +468,12 @@ class RequestTest < ActiveSupport::TestCase assert request.formats.empty? end + test "formats with xhr request" do + request = stub_request 'HTTP_X_REQUESTED_WITH' => "XMLHttpRequest" + request.expects(:parameters).at_least_once.returns({}) + assert_equal [Mime::JS], request.formats + end + test "ignore_accept_header" do ActionDispatch::Request.ignore_accept_header = true diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index ba7506721f..1938348375 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -504,6 +504,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' } match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/ + + scope '/italians' do + match '/writers', :to => 'italians#writers', :constraints => ::TestRoutingMapper::IpRestrictor + match '/sculptors', :to => 'italians#sculptors' + match '/painters/:painter', :to => 'italians#painters', :constraints => {:painter => /michelangelo/} + end end end @@ -2229,6 +2235,20 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest verify_redirect 'http://www.example.com/countries/all/cities' end + def test_constraints_block_not_carried_to_following_routes + get '/italians/writers' + assert_equal 'Not Found', @response.body + + get '/italians/sculptors' + assert_equal 'italians#sculptors', @response.body + + get '/italians/painters/botticelli' + assert_equal 'Not Found', @response.body + + get '/italians/painters/michelangelo' + assert_equal 'italians#painters', @response.body + end + def test_custom_resource_actions_defined_using_string get '/customers/inactive' assert_equal 'customers#inactive', @response.body diff --git a/actionpack/test/fixtures/test/_200.html.erb b/actionpack/test/fixtures/test/_200.html.erb new file mode 100644 index 0000000000..c9f45675dc --- /dev/null +++ b/actionpack/test/fixtures/test/_200.html.erb @@ -0,0 +1 @@ +<h1>Invalid partial</h1> diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index d5bd7256f7..d93433deac 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -443,7 +443,7 @@ class AssetTagHelperTest < ActionView::TestCase def test_image_tag_windows_behaviour old_asset_id, ENV["RAILS_ASSET_ID"] = ENV["RAILS_ASSET_ID"], "1" - # This simulates the behaviour of File#exist? on windows when testing a file ending in "." + # This simulates the behavior of File#exist? on windows when testing a file ending in "." # If the file "rails.png" exists, windows will return true when asked if "rails.png." exists (notice trailing ".") # OS X, linux etc will return false in this case. File.stubs(:exist?).with('template/../fixtures/public/images/rails.png.').returns(true) @@ -481,7 +481,7 @@ class AssetTagHelperTest < ActionView::TestCase end def test_timebased_asset_id - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s + expected_time = File.mtime(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).to_i.to_s assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") end @@ -512,7 +512,7 @@ class AssetTagHelperTest < ActionView::TestCase def test_timebased_asset_id_with_relative_url_root @controller.config.relative_url_root = "/collaboration/hieraki" - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s + expected_time = File.mtime(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).to_i.to_s assert_equal %(<img alt="Rails" src="#{@controller.config.relative_url_root}/images/rails.png?#{expected_time}" />), image_tag("rails.png") end diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 4187a0ac78..68b2ed45d1 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -98,6 +98,15 @@ module RenderTestCases assert_equal "only partial", @view.render("test/partial_only", :counter_counter => 5) end + def test_render_partial_with_invalid_name + @view.render(:partial => "test/200") + flunk "Render did not raise ArgumentError" + rescue ArgumentError => e + assert_equal "The partial name (test/200) is not a valid Ruby identifier; " + + "make sure your partial name starts with a letter or underscore, " + + "and is followed by any combinations of letters, numbers, or underscores.", e.message + end + def test_render_partial_with_errors @view.render(:partial => "test/raise") flunk "Render did not raise Template::Error" diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index f11d1bba15..b9161b62c5 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -4,33 +4,29 @@ require 'sprockets/helpers/rails_helper' require 'mocha' class SprocketsHelperTest < ActionView::TestCase - tests Sprockets::Helpers::RailsHelper + include Sprockets::Helpers::RailsHelper attr_accessor :assets + class MockRequest + def protocol() 'http://' end + def ssl?() false end + def host_with_port() 'localhost' end + end + def setup super - @controller = BasicController.new - @controller.stubs(:params).returns({}) - - @request = Class.new do - def protocol() 'http://' end - def ssl?() false end - def host_with_port() 'localhost' end - end.new - - @controller.request = @request + @controller = BasicController.new + @controller.request = MockRequest.new @assets = Sprockets::Environment.new - @assets.paths << FIXTURES.join("sprockets/app/javascripts") - @assets.paths << FIXTURES.join("sprockets/app/stylesheets") - @assets.paths << FIXTURES.join("sprockets/app/images") + @assets.append_path(FIXTURES.join("sprockets/app/javascripts")) + @assets.append_path(FIXTURES.join("sprockets/app/stylesheets")) + @assets.append_path(FIXTURES.join("sprockets/app/images")) - application = Object.new + application = Struct.new(:config, :assets).new(config, @assets) Rails.stubs(:application).returns(application) - application.stubs(:config).returns(config) - application.stubs(:assets).returns(@assets) @config = config @config.action_controller ||= ActiveSupport::InheritableOptions.new @config.perform_caching = true @@ -41,7 +37,7 @@ class SprocketsHelperTest < ActionView::TestCase end test "asset_path" do - assert_equal "/assets/logo-9c0a079bdd7701d7e729bd956823d153.png", + assert_match %r{/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") end @@ -54,7 +50,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_equal "/dir/audio", asset_path("/dir/audio") end - + test "asset_path with absolute urls" do assert_equal "http://www.example.com/video/play", asset_path("http://www.example.com/video/play") @@ -74,7 +70,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{http://assets-\d.example.com/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") end - + test "With a proc asset host that returns no protocol the url should be protocol relative" do @controller.config.asset_host = Proc.new do |asset| "assets-999.example.com" @@ -116,7 +112,7 @@ class SprocketsHelperTest < ActionView::TestCase @config.action_controller.default_asset_host_protocol = :request @config.action_controller.perform_caching = true - assert_equal "/assets/logo-9c0a079bdd7701d7e729bd956823d153.png", + assert_match %r{/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") end @@ -127,12 +123,12 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript path" do - assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.js", + assert_match %r{/assets/application-[0-9a-f]+.js}, asset_path(:application, "js") - assert_equal "/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", + assert_match %r{/assets/xmlhr-[0-9a-f]+.js}, asset_path("xmlhr", "js") - assert_equal "/assets/dir/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", + assert_match %r{/assets/dir/xmlhr-[0-9a-f]+.js}, asset_path("dir/xmlhr.js", "js") assert_equal "/dir/xmlhr.js", @@ -145,28 +141,28 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript include tag" do - assert_equal '<script src="/assets/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_match %r{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>}, javascript_include_tag(:application) - assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>}, javascript_include_tag("xmlhr") - assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>}, javascript_include_tag("xmlhr.js") assert_equal '<script src="http://www.example.com/xmlhr" type="text/javascript"></script>', javascript_include_tag("http://www.example.com/xmlhr") - assert_equal "<script src=\"/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>\n<script src=\"/assets/application-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>", + assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>}, javascript_include_tag(:application, :debug => true) - assert_equal "<script src=\"/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js\" type=\"text/javascript\"></script>\n<script src=\"/assets/extra-d41d8cd98f00b204e9800998ecf8427e.js\" type=\"text/javascript\"></script>", + assert_match %r{<script src=\"/assets/xmlhr-[0-9a-f]+.js\" type=\"text/javascript\"></script>\n<script src=\"/assets/extra-[0-9a-f]+.js\" type=\"text/javascript\"></script>}, javascript_include_tag("xmlhr", "extra") end test "stylesheet path" do - assert_equal "/assets/application-68b329da9893e34099c7d8ad5cb9c940.css", asset_path(:application, "css") + assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, "css") - assert_equal "/assets/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("style", "css") - assert_equal "/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("dir/style.css", "css") + assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css") + assert_match %r{/assets/dir/style-[0-9a-f]+.css}, asset_path("dir/style.css", "css") assert_equal "/dir/style.css", asset_path("/dir/style.css", "css") assert_equal "http://www.example.com/css/style", @@ -176,37 +172,37 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do - assert_equal '<link href="/assets/application-68b329da9893e34099c7d8ad5cb9c940.css" media="screen" rel="stylesheet" type="text/css" />', + assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag(:application) - assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag("style") - assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag("style.css") assert_equal '<link href="http://www.example.com/style.css" media="screen" rel="stylesheet" type="text/css" />', stylesheet_link_tag("http://www.example.com/style.css") - assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />', + assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="all" rel="stylesheet" type="text/css" />}, stylesheet_link_tag("style", :media => "all") - assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />', + assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="print" rel="stylesheet" type="text/css" />}, stylesheet_link_tag("style", :media => "print") - assert_equal "<link href=\"/assets/style-d41d8cd98f00b204e9800998ecf8427e.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/assets/application-68b329da9893e34099c7d8ad5cb9c940.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />", + assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag(:application, :debug => true) - assert_equal "<link href=\"/assets/style-d41d8cd98f00b204e9800998ecf8427e.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/assets/extra-d41d8cd98f00b204e9800998ecf8427e.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />", + assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/extra-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag("style", "extra") end test "alternate asset prefix" do stubs(:asset_prefix).returns("/themes/test") - assert_equal "/themes/test/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("style", "css") + assert_match %r{/themes/test/style-[0-9a-f]+.css}, asset_path("style", "css") end test "alternate asset environment" do assets = Sprockets::Environment.new - assets.paths << FIXTURES.join("sprockets/alternate/stylesheets") + assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) stubs(:asset_environment).returns(assets) - assert_equal "/assets/style-df0b97ad35a8e1f7f61097461f77c19a.css", asset_path("style", "css") + assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css") end end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index 3d0bbba435..bf789cd8b7 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -39,7 +39,7 @@ class PeopleHelperTest < ActionView::TestCase with_test_route_set do person = mock(:name => "David") person.class.extend ActiveModel::Naming - _routes.url_helpers.expects(:hash_for_mocha_mock_path).with(person).returns("/people/1") + expects(:mocha_mock_path).with(person).returns("/people/1") assert_equal '<a href="/people/1">David</a>', link_to_person(person) end end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index a70c02a429..78245c1f95 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -386,13 +386,11 @@ class UrlHelperTest < ActiveSupport::TestCase def test_mail_to_with_javascript snippet = mail_to("me@domain.com", "My email", :encode => "javascript") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%4d%79%20%65%6d%61%69%6c%3c%5c%2f%61%3e%27%29%3b'))</script>", snippet - assert snippet.html_safe? end def test_mail_to_with_javascript_unicode snippet = mail_to("unicode@example.com", "Ășnicode", :encode => "javascript") assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%75%6e%69%63%6f%64%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%5c%22%3e%c3%ba%6e%69%63%6f%64%65%3c%5c%2f%61%3e%27%29%3b'))</script>", snippet - assert snippet.html_safe end def test_mail_with_options @@ -421,6 +419,12 @@ class UrlHelperTest < ActiveSupport::TestCase assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%5c%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%5c%22%3e%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%3c%5c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", nil, :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") end + def test_mail_to_returns_html_safe_string + assert mail_to("david@loudthinking.com").html_safe? + assert mail_to("me@domain.com", "My email", :encode => "javascript").html_safe? + assert mail_to("me@domain.com", "My email", :encode => "hex").html_safe? + end + # TODO: button_to looks at this ... why? def protect_against_forgery? false |