aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/routing_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-26 13:57:11 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-26 13:57:11 +0100
commit1dca7ebc93ebf067a73d23ddc33d97229a0b482f (patch)
tree6070c9418bf939427b7d1e7f1018dd0ec09ff1e3 /railties/test/application/routing_test.rb
parente6da2f651ffc24e5be3842051df73493d158a6b4 (diff)
downloadrails-1dca7ebc93ebf067a73d23ddc33d97229a0b482f.tar.gz
rails-1dca7ebc93ebf067a73d23ddc33d97229a0b482f.tar.bz2
rails-1dca7ebc93ebf067a73d23ddc33d97229a0b482f.zip
Refactor railties test, break huge files in smaller chunks and move initializers to application folder.
Diffstat (limited to 'railties/test/application/routing_test.rb')
-rw-r--r--railties/test/application/routing_test.rb78
1 files changed, 33 insertions, 45 deletions
diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb
index 50cb9e3acc..b93e349a46 100644
--- a/railties/test/application/routing_test.rb
+++ b/railties/test/application/routing_test.rb
@@ -14,7 +14,6 @@ module ApplicationTests
def app
@app ||= begin
require "#{app_path}/config/environment"
-
Rails.application
end
end
@@ -26,7 +25,7 @@ module ApplicationTests
test "simple controller" do
controller :foo, <<-RUBY
- class FooController < ActionController::Base
+ class FooController < ApplicationController
def index
render :text => "foo"
end
@@ -43,9 +42,36 @@ module ApplicationTests
assert_equal 'foo', last_response.body
end
+ test "simple controller with helper" do
+ controller :foo, <<-RUBY
+ class FooController < ApplicationController
+ def index
+ render :inline => "<%= foo_or_bar? %>"
+ end
+ end
+ RUBY
+
+ app_file 'app/helpers/bar_helper.rb', <<-RUBY
+ module BarHelper
+ def foo_or_bar?
+ "bar"
+ end
+ end
+ RUBY
+
+ app_file 'config/routes.rb', <<-RUBY
+ AppTemplate::Application.routes.draw do |map|
+ match ':controller(/:action)'
+ end
+ RUBY
+
+ get '/foo'
+ assert_equal 'bar', last_response.body
+ end
+
test "multiple controllers" do
controller :foo, <<-RUBY
- class FooController < ActionController::Base
+ class FooController < ApplicationController
def index
render :text => "foo"
end
@@ -75,7 +101,7 @@ module ApplicationTests
test "nested controller" do
controller 'foo', <<-RUBY
- class FooController < ActionController::Base
+ class FooController < ApplicationController
def index
render :text => "foo"
end
@@ -84,7 +110,7 @@ module ApplicationTests
controller 'admin/foo', <<-RUBY
module Admin
- class FooController < ActionController::Base
+ class FooController < ApplicationController
def index
render :text => "admin::foo"
end
@@ -105,47 +131,9 @@ module ApplicationTests
assert_equal 'admin::foo', last_response.body
end
- test "merges with plugin routes" do
- controller 'foo', <<-RUBY
- class FooController < ActionController::Base
- def index
- render :text => "foo"
- end
- end
- RUBY
-
- app_file 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do |map|
- match 'foo', :to => 'foo#index'
- end
- RUBY
-
- plugin 'bar', 'require File.dirname(__FILE__) + "/app/controllers/bar"' do |plugin|
- plugin.write 'app/controllers/bar.rb', <<-RUBY
- class BarController < ActionController::Base
- def index
- render :text => "bar"
- end
- end
- RUBY
-
- plugin.write 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do |map|
- match 'bar', :to => 'bar#index'
- end
- RUBY
- end
-
- get '/foo'
- assert_equal 'foo', last_response.body
-
- get '/bar'
- assert_equal 'bar', last_response.body
- end
-
test "reloads routes when configuration is changed" do
controller :foo, <<-RUBY
- class FooController < ActionController::Base
+ class FooController < ApplicationController
def bar
render :text => "bar"
end
@@ -191,7 +179,7 @@ module ApplicationTests
RUBY
controller 'yazilar', <<-RUBY
- class YazilarController < ActionController::Base
+ class YazilarController < ApplicationController
def index
render :text => 'yazilar#index'
end