提交 47fe14bf 编写于 作者: C Carlhuda

Silence test deprecation warnings

上级 bae691f6
...@@ -66,6 +66,16 @@ def default_url_options(options = nil) ...@@ -66,6 +66,16 @@ def default_url_options(options = nil)
end end
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 class ControllerClassTests < ActiveSupport::TestCase
def test_controller_path def test_controller_path
assert_equal 'empty', EmptyController.controller_path assert_equal 'empty', EmptyController.controller_path
...@@ -162,8 +172,8 @@ def test_get_on_hidden_should_fail ...@@ -162,8 +172,8 @@ def test_get_on_hidden_should_fail
end end
end end
class DefaultUrlOptionsTest < ActionController::TestCase class UrlOptionsTest < ActionController::TestCase
tests DefaultUrlOptionsController tests UrlOptionsController
def setup def setup
super super
...@@ -174,7 +184,7 @@ def setup ...@@ -174,7 +184,7 @@ def setup
def test_default_url_options_are_used_if_set def test_default_url_options_are_used_if_set
with_routing do |set| with_routing do |set|
set.draw do |map| 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' match ':controller/:action'
end end
...@@ -184,6 +194,33 @@ def test_default_url_options_are_used_if_set ...@@ -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/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/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
end 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 end
def test_default_url_options_are_used_in_non_positional_parameters 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 ...@@ -195,19 +232,21 @@ def test_default_url_options_are_used_in_non_positional_parameters
match ':controller/:action' match ':controller/:action'
end 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 '/en/descriptions/1', @response.body
assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") assert_equal '/en/descriptions', @controller.send(:descriptions_path)
assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl")
assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl")
assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml")
assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml")
assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) assert_equal '/en/descriptions/1', @controller.send(:description_path, 1)
assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1)
assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl")
assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") 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
end end
......
...@@ -426,7 +426,7 @@ def default_url_options(options = nil) ...@@ -426,7 +426,7 @@ def default_url_options(options = nil)
end end
with_url_helper_routing do 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 assert_equal 'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route', @response.body
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册