diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-21 20:15:27 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-21 20:15:27 -0600 |
commit | 426348b48403f664cc10e8ec545b640e56c1c090 (patch) | |
tree | abbcac7646f0dba168a5685ee646c3e7f90d8e66 | |
parent | 36624b2c709925bcabb49d12082b9dd9d28c4c5c (diff) | |
download | rails-426348b48403f664cc10e8ec545b640e56c1c090.tar.gz rails-426348b48403f664cc10e8ec545b640e56c1c090.tar.bz2 rails-426348b48403f664cc10e8ec545b640e56c1c090.zip |
Update routes.rb template to use App name
-rw-r--r-- | railties/lib/rails/application.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/routes.rb | 2 | ||||
-rw-r--r-- | railties/test/application/initializer_test.rb | 10 | ||||
-rw-r--r-- | railties/test/application/routing_test.rb | 14 | ||||
-rw-r--r-- | railties/test/initializer/initialize_i18n_test.rb | 1 | ||||
-rw-r--r-- | railties/test/initializer/path_test.rb | 1 | ||||
-rw-r--r-- | railties/test/paths_test.rb | 3 |
9 files changed, 29 insertions, 14 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 498fd6a723..4e21287496 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -41,6 +41,10 @@ module Rails end end + def routes + ActionController::Routing::Routes + end + def call(env) new.call(env) end diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 2efdf29127..f95b15acce 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -273,7 +273,7 @@ module Rails # def route(routing_code) log :route, routing_code - sentinel = "ActionController::Routing::Routes.draw do |map|" + sentinel = "routes.draw do |map|" in_root do inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false } diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index ae18fa843b..b8f2911021 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -62,9 +62,9 @@ module Rails::Generators empty_directory "config" inside "config" do - copy_file "routes.rb" - template "application.rb" - template "environment.rb" + template "routes.rb" + template "application.rb" + template "environment.rb" directory "environments" directory "initializers" diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index 0d1b6bab4f..1959d3387f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -1,4 +1,4 @@ -ActionController::Routing::Routes.draw do |map| +<%= app_const %>.routes.draw do |map| # The priority is based upon order of creation: # first created -> highest priority. diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index fa00d287ca..031fdc2e9f 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -15,6 +15,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.root = app_path end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert $:.include?("#{app_path}/app/models") @@ -45,6 +46,7 @@ module ApplicationTests config.root = app_path config.eager_load_paths = "#{app_path}/lib" end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! @@ -55,6 +57,7 @@ module ApplicationTests app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'" assert_nil $initialize_test_set_from_env Rails::Initializer.run { |config| config.root = app_path } + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_equal "success", $initialize_test_set_from_env end @@ -75,6 +78,7 @@ module ApplicationTests config.after_initialize { $test_after_initialize_block1 = "success" } config.after_initialize { $test_after_initialize_block2 = "congratulations" } end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_equal "success", $test_after_initialize_block1 @@ -88,6 +92,7 @@ module ApplicationTests config.after_initialize # don't pass a block, this is what we're testing! config.after_initialize { $test_after_initialize_block2 = "congratulations" } end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_equal "success", $test_after_initialize_block1 @@ -100,6 +105,7 @@ module ApplicationTests config.root = app_path config.i18n.default_locale = :de end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_equal :de, I18n.default_locale @@ -137,6 +143,7 @@ module ApplicationTests config.root = app_path config.action_controller.session_store = :cookie_store end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) @@ -155,6 +162,7 @@ module ApplicationTests c.root = app_path c.action_controller.session_store = :active_record_store end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore] @@ -179,6 +187,7 @@ module ApplicationTests c.root = app_path c.frameworks -= [:action_view] end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_equal nil, ActionMailer::Base.template_root @@ -189,6 +198,7 @@ module ApplicationTests Rails::Initializer.run do |c| c.root = app_path end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! assert_instance_of Pathname, Rails.root end diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index 1add941ee0..7803794307 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -29,7 +29,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -56,7 +56,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -88,7 +88,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -110,7 +110,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match 'foo', :to => 'foo#index' end RUBY @@ -125,7 +125,7 @@ module ApplicationTests RUBY plugin.write 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match 'bar', :to => 'bar#index' end RUBY @@ -152,7 +152,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match 'foo', :to => 'foo#bar' end RUBY @@ -161,7 +161,7 @@ module ApplicationTests assert_equal 'bar', last_response.body app_file 'config/routes.rb', <<-RUBY - ActionController::Routing::Routes.draw do |map| + AppTemplate.routes.draw do |map| match 'foo', :to => 'foo#baz' end RUBY diff --git a/railties/test/initializer/initialize_i18n_test.rb b/railties/test/initializer/initialize_i18n_test.rb index 076816d73b..4642e53cfc 100644 --- a/railties/test/initializer/initialize_i18n_test.rb +++ b/railties/test/initializer/initialize_i18n_test.rb @@ -16,6 +16,7 @@ module InitializerTests c.root = app_path c.i18n.load_path << "my/other/locale.yml" end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb index 1b58a58555..3724655c0f 100644 --- a/railties/test/initializer/path_test.rb +++ b/railties/test/initializer/path_test.rb @@ -14,6 +14,7 @@ class PathsTest < Test::Unit::TestCase ActionController::Base.session_store = nil end end + Object.const_set(:AppTemplate, Rails.application) Rails.initialize! @paths = Rails.application.config.paths end diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index c724799d64..d60d6177f6 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -2,7 +2,6 @@ require 'abstract_unit' require 'rails/paths' class PathsTest < ActiveSupport::TestCase - def setup @root = Rails::Application::Root.new("/foo/bar") end @@ -228,4 +227,4 @@ class PathsTest < ActiveSupport::TestCase @root.app.eager_load! assert_equal ["/foo/bar/app"], @root.load_paths end -end
\ No newline at end of file +end |