1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Silence test deprecation warnings

This commit is contained in:
Carlhuda 2010-02-26 15:34:12 -08:00
parent bae691f61a
commit 47fe14bfcc
2 changed files with 56 additions and 17 deletions

View file

@ -66,6 +66,16 @@ class DefaultUrlOptionsController < ActionController::Base
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,6 +172,31 @@ class PerformActionTest < ActionController::TestCase
end
end
class UrlOptionsTest < ActionController::TestCase
tests UrlOptionsController
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 => 'url_options#from_view', :as => :from_view
match ':controller/:action'
end
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
class DefaultUrlOptionsTest < ActionController::TestCase
tests DefaultUrlOptionsController
@ -178,11 +213,13 @@ class DefaultUrlOptionsTest < ActionController::TestCase
match ':controller/:action'
end
get :from_view, :route => "from_view_url"
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')
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
@ -195,19 +232,21 @@ class DefaultUrlOptionsTest < ActionController::TestCase
match ':controller/:action'
end
get :from_view, :route => "description_path(1)"
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")
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 file

@ -426,7 +426,7 @@ class UrlHelperControllerTest < ActionController::TestCase
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