mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Stop using with_controllers in tests
This commit is contained in:
parent
e00f57e208
commit
6c2a73909e
1 changed files with 80 additions and 104 deletions
|
@ -747,13 +747,10 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def default_route_set
|
def default_route_set
|
||||||
@default_route_set ||= begin
|
@default_route_set ||= begin
|
||||||
set = nil
|
|
||||||
ActionController::Routing.with_controllers(['accounts']) do
|
|
||||||
set = ROUTING::RouteSet.new
|
set = ROUTING::RouteSet.new
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/:controller/:action/:id/'
|
map.connect '/:controller/:action/:id/'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
set
|
set
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -940,7 +937,6 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_draw_default_route
|
def test_draw_default_route
|
||||||
ActionController::Routing.with_controllers(['users']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/:controller/:action/:id'
|
map.connect '/:controller/:action/:id'
|
||||||
end
|
end
|
||||||
|
@ -953,19 +949,15 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10'))
|
assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10'))
|
||||||
assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10/'))
|
assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10/'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_draw_default_route_with_default_controller
|
def test_draw_default_route_with_default_controller
|
||||||
ActionController::Routing.with_controllers(['users']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/:controller/:action/:id', :controller => 'users'
|
map.connect '/:controller/:action/:id', :controller => 'users'
|
||||||
end
|
end
|
||||||
assert_equal({:controller => 'users', :action => 'index'}, set.recognize_path('/'))
|
assert_equal({:controller => 'users', :action => 'index'}, set.recognize_path('/'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_route_with_parameter_shell
|
def test_route_with_parameter_shell
|
||||||
ActionController::Routing.with_controllers(['users', 'pages']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/
|
map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/
|
||||||
map.connect '/:controller/:action/:id'
|
map.connect '/:controller/:action/:id'
|
||||||
|
@ -978,7 +970,6 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/pages/show/10'))
|
assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/pages/show/10'))
|
||||||
assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10'))
|
assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_route_requirements_with_anchor_chars_are_invalid
|
def test_route_requirements_with_anchor_chars_are_invalid
|
||||||
assert_raise ArgumentError do
|
assert_raise ArgumentError do
|
||||||
|
@ -1568,9 +1559,7 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named'))
|
assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_interpolation_chunk_should_respect_raw
|
def test_interpolation_chunk_should_respect_raw
|
||||||
ActionController::Routing.with_controllers(['hello']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/Hello World', :controller => 'hello'
|
map.connect '/Hello World', :controller => 'hello'
|
||||||
end
|
end
|
||||||
|
@ -1579,10 +1568,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => "hello", :action => "index"}, set.recognize_path('/Hello World'))
|
assert_equal({:controller => "hello", :action => "index"}, set.recognize_path('/Hello World'))
|
||||||
assert_raise(ActionController::RoutingError) { set.recognize_path('/Hello%20World') }
|
assert_raise(ActionController::RoutingError) { set.recognize_path('/Hello%20World') }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_value_should_not_be_double_unescaped
|
def test_value_should_not_be_double_unescaped
|
||||||
ActionController::Routing.with_controllers(['foo']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/Карта', :controller => 'foo'
|
map.connect '/Карта', :controller => 'foo'
|
||||||
end
|
end
|
||||||
|
@ -1591,10 +1578,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Карта'))
|
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Карта'))
|
||||||
assert_raise(ActionController::RoutingError) { set.recognize_path('/%D0%9A%D0%B0%D1%80%D1%82%D0%B0') }
|
assert_raise(ActionController::RoutingError) { set.recognize_path('/%D0%9A%D0%B0%D1%80%D1%82%D0%B0') }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_regexp_chunk_should_escape_specials
|
def test_regexp_chunk_should_escape_specials
|
||||||
ActionController::Routing.with_controllers(['foo', 'bar']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/Hello*World', :controller => 'foo'
|
map.connect '/Hello*World', :controller => 'foo'
|
||||||
map.connect '/HelloWorld', :controller => 'bar'
|
map.connect '/HelloWorld', :controller => 'bar'
|
||||||
|
@ -1606,10 +1591,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Hello*World'))
|
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Hello*World'))
|
||||||
assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/HelloWorld'))
|
assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/HelloWorld'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_regexp_chunk_should_add_question_mark_for_optionals
|
def test_regexp_chunk_should_add_question_mark_for_optionals
|
||||||
ActionController::Routing.with_controllers(['foo', 'bar']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/', :controller => 'foo'
|
map.connect '/', :controller => 'foo'
|
||||||
map.connect '/hello', :controller => 'bar'
|
map.connect '/hello', :controller => 'bar'
|
||||||
|
@ -1621,10 +1604,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/'))
|
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/'))
|
||||||
assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/hello'))
|
assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/hello'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_assign_route_options_with_anchor_chars
|
def test_assign_route_options_with_anchor_chars
|
||||||
ActionController::Routing.with_controllers(['cars']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/cars/:action/:person/:car/', :controller => 'cars'
|
map.connect '/cars/:action/:person/:car/', :controller => 'cars'
|
||||||
end
|
end
|
||||||
|
@ -1633,10 +1614,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_equal({:controller => "cars", :action => "buy", :person => "1", :car => "2"}, set.recognize_path('/cars/buy/1/2'))
|
assert_equal({:controller => "cars", :action => "buy", :person => "1", :car => "2"}, set.recognize_path('/cars/buy/1/2'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_segmentation_of_dot_path
|
def test_segmentation_of_dot_path
|
||||||
ActionController::Routing.with_controllers(['books']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/books/:action.rss', :controller => 'books'
|
map.connect '/books/:action.rss', :controller => 'books'
|
||||||
end
|
end
|
||||||
|
@ -1645,10 +1624,8 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list.rss'))
|
assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list.rss'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_segmentation_of_dynamic_dot_path
|
def test_segmentation_of_dynamic_dot_path
|
||||||
ActionController::Routing.with_controllers(['books']) do
|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.connect '/books/:action.:format', :controller => 'books'
|
map.connect '/books/:action.:format', :controller => 'books'
|
||||||
end
|
end
|
||||||
|
@ -1663,7 +1640,6 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list'))
|
assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list'))
|
||||||
assert_equal({:controller => "books", :action => "index"}, set.recognize_path('/books'))
|
assert_equal({:controller => "books", :action => "index"}, set.recognize_path('/books'))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_slashes_are_implied
|
def test_slashes_are_implied
|
||||||
['/:controller/:action/:id/', '/:controller/:action/:id',
|
['/:controller/:action/:id/', '/:controller/:action/:id',
|
||||||
|
|
Loading…
Reference in a new issue