Browse files

Silence test deprecation warnings

  • Loading branch information...
1 parent bae691f commit 47fe14bfcc553acfd4c44434636529f25054a751 Carlhuda committed Feb 26, 2010
Showing with 56 additions and 17 deletions.
  1. +55 −16 actionpack/test/controller/base_test.rb
  2. +1 −1 actionpack/test/template/url_helper_test.rb
View
71 actionpack/test/controller/base_test.rb
@@ -66,6 +66,16 @@ def default_url_options(options = nil)
end
end
+class UrlOptionsController < ActionController::Base
+ def from_view
+ render :inline => "<%= #{params[:route]} %>"
+ end
+
+ def url_options
+ super.merge(:host => 'www.override.com', :action => 'new', :locale => 'en')
+ end
+end
+
class ControllerClassTests < ActiveSupport::TestCase
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
@@ -162,8 +172,8 @@ def test_get_on_hidden_should_fail
end
end
-class DefaultUrlOptionsTest < ActionController::TestCase
- tests DefaultUrlOptionsController
+class UrlOptionsTest < ActionController::TestCase
+ tests UrlOptionsController
def setup
super
@@ -174,7 +184,7 @@ def setup
def test_default_url_options_are_used_if_set
with_routing do |set|
set.draw do |map|
- match 'from_view', :to => 'default_url_options#from_view', :as => :from_view
+ match 'from_view', :to => 'url_options#from_view', :as => :from_view
match ':controller/:action'
end
@@ -184,6 +194,33 @@ def test_default_url_options_are_used_if_set
assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
end
+ end
+end
+
+class DefaultUrlOptionsTest < ActionController::TestCase
+ tests DefaultUrlOptionsController
+
+ def setup
+ super
+ @request.host = 'www.example.com'
+ rescue_action_in_public!
+ end
+
+ def test_default_url_options_are_used_if_set
+ with_routing do |set|
+ set.draw do |map|
+ match 'from_view', :to => 'default_url_options#from_view', :as => :from_view
+ match ':controller/:action'
+ end
+
+ assert_deprecated do
+ get :from_view, :route => "from_view_url"
+
+ assert_equal 'http://www.override.com/from_view?locale=en', @response.body
+ assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
+ assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
+ end
+ end
end
def test_default_url_options_are_used_in_non_positional_parameters
@@ -195,19 +232,21 @@ def test_default_url_options_are_used_in_non_positional_parameters
match ':controller/:action'
end
- get :from_view, :route => "description_path(1)"
-
- assert_equal '/en/descriptions/1', @response.body
- assert_equal '/en/descriptions', @controller.send(:descriptions_path)
- assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl")
- assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl")
- assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml")
- assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml")
- assert_equal '/en/descriptions/1', @controller.send(:description_path, 1)
- assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1)
- assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl")
- assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml")
- assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml")
+ assert_deprecated do
+ get :from_view, :route => "description_path(1)"
+
+ assert_equal '/en/descriptions/1', @response.body
+ assert_equal '/en/descriptions', @controller.send(:descriptions_path)
+ assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl")
+ assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl")
+ assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml")
+ assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml")
+ assert_equal '/en/descriptions/1', @controller.send(:description_path, 1)
+ assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1)
+ assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl")
+ assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml")
+ assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml")
+ end
end
end
View
2 actionpack/test/template/url_helper_test.rb
@@ -426,7 +426,7 @@ def default_url_options(options = nil)
end
with_url_helper_routing do
- get :show_named_route, :kind => 'url'
+ assert_deprecated { get :show_named_route, :kind => 'url' }
assert_equal 'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route', @response.body
end
end

0 comments on commit 47fe14b

Please sign in to comment.