From 1dca7ebc93ebf067a73d23ddc33d97229a0b482f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 26 Jan 2010 13:57:11 +0100 Subject: Refactor railties test, break huge files in smaller chunks and move initializers to application folder. --- railties/test/application/routing_test.rb | 78 +++++++++++++------------------ 1 file changed, 33 insertions(+), 45 deletions(-) (limited to 'railties/test/application/routing_test.rb') 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 -- cgit v1.2.3