1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update routes.rb template to use App name

This commit is contained in:
Joshua Peek 2009-12-21 20:15:27 -06:00
parent 36624b2c70
commit 426348b484
9 changed files with 29 additions and 14 deletions

View file

@ -41,6 +41,10 @@ module Rails
end
end
def routes
ActionController::Routing::Routes
end
def call(env)
new.call(env)
end

View file

@ -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 }

View file

@ -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"

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
end