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:
parent
36624b2c70
commit
426348b484
9 changed files with 29 additions and 14 deletions
|
@ -41,6 +41,10 @@ module Rails
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def routes
|
||||||
|
ActionController::Routing::Routes
|
||||||
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
new.call(env)
|
new.call(env)
|
||||||
end
|
end
|
||||||
|
|
|
@ -273,7 +273,7 @@ module Rails
|
||||||
#
|
#
|
||||||
def route(routing_code)
|
def route(routing_code)
|
||||||
log :route, routing_code
|
log :route, routing_code
|
||||||
sentinel = "ActionController::Routing::Routes.draw do |map|"
|
sentinel = "routes.draw do |map|"
|
||||||
|
|
||||||
in_root do
|
in_root do
|
||||||
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
||||||
|
|
|
@ -62,9 +62,9 @@ module Rails::Generators
|
||||||
empty_directory "config"
|
empty_directory "config"
|
||||||
|
|
||||||
inside "config" do
|
inside "config" do
|
||||||
copy_file "routes.rb"
|
template "routes.rb"
|
||||||
template "application.rb"
|
template "application.rb"
|
||||||
template "environment.rb"
|
template "environment.rb"
|
||||||
|
|
||||||
directory "environments"
|
directory "environments"
|
||||||
directory "initializers"
|
directory "initializers"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ActionController::Routing::Routes.draw do |map|
|
<%= app_const %>.routes.draw do |map|
|
||||||
# The priority is based upon order of creation:
|
# The priority is based upon order of creation:
|
||||||
# first created -> highest priority.
|
# first created -> highest priority.
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ module ApplicationTests
|
||||||
Rails::Initializer.run do |config|
|
Rails::Initializer.run do |config|
|
||||||
config.root = app_path
|
config.root = app_path
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
|
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
assert $:.include?("#{app_path}/app/models")
|
assert $:.include?("#{app_path}/app/models")
|
||||||
|
@ -45,6 +46,7 @@ module ApplicationTests
|
||||||
config.root = app_path
|
config.root = app_path
|
||||||
config.eager_load_paths = "#{app_path}/lib"
|
config.eager_load_paths = "#{app_path}/lib"
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
|
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ module ApplicationTests
|
||||||
app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'"
|
app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'"
|
||||||
assert_nil $initialize_test_set_from_env
|
assert_nil $initialize_test_set_from_env
|
||||||
Rails::Initializer.run { |config| config.root = app_path }
|
Rails::Initializer.run { |config| config.root = app_path }
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
assert_equal "success", $initialize_test_set_from_env
|
assert_equal "success", $initialize_test_set_from_env
|
||||||
end
|
end
|
||||||
|
@ -75,6 +78,7 @@ module ApplicationTests
|
||||||
config.after_initialize { $test_after_initialize_block1 = "success" }
|
config.after_initialize { $test_after_initialize_block1 = "success" }
|
||||||
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
|
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
assert_equal "success", $test_after_initialize_block1
|
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 # don't pass a block, this is what we're testing!
|
||||||
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
|
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
assert_equal "success", $test_after_initialize_block1
|
assert_equal "success", $test_after_initialize_block1
|
||||||
|
@ -100,6 +105,7 @@ module ApplicationTests
|
||||||
config.root = app_path
|
config.root = app_path
|
||||||
config.i18n.default_locale = :de
|
config.i18n.default_locale = :de
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
assert_equal :de, I18n.default_locale
|
assert_equal :de, I18n.default_locale
|
||||||
|
@ -137,6 +143,7 @@ module ApplicationTests
|
||||||
config.root = app_path
|
config.root = app_path
|
||||||
config.action_controller.session_store = :cookie_store
|
config.action_controller.session_store = :cookie_store
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
|
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
|
||||||
|
@ -155,6 +162,7 @@ module ApplicationTests
|
||||||
c.root = app_path
|
c.root = app_path
|
||||||
c.action_controller.session_store = :active_record_store
|
c.action_controller.session_store = :active_record_store
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
|
expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
|
||||||
|
@ -179,6 +187,7 @@ module ApplicationTests
|
||||||
c.root = app_path
|
c.root = app_path
|
||||||
c.frameworks -= [:action_view]
|
c.frameworks -= [:action_view]
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
assert_equal nil, ActionMailer::Base.template_root
|
assert_equal nil, ActionMailer::Base.template_root
|
||||||
|
@ -189,6 +198,7 @@ module ApplicationTests
|
||||||
Rails::Initializer.run do |c|
|
Rails::Initializer.run do |c|
|
||||||
c.root = app_path
|
c.root = app_path
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
assert_instance_of Pathname, Rails.root
|
assert_instance_of Pathname, Rails.root
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match ':controller(/:action)'
|
match ':controller(/:action)'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -56,7 +56,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match ':controller(/:action)'
|
match ':controller(/:action)'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -88,7 +88,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match ':controller(/:action)'
|
match ':controller(/:action)'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -110,7 +110,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match 'foo', :to => 'foo#index'
|
match 'foo', :to => 'foo#index'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -125,7 +125,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
plugin.write 'config/routes.rb', <<-RUBY
|
plugin.write 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match 'bar', :to => 'bar#index'
|
match 'bar', :to => 'bar#index'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -152,7 +152,7 @@ module ApplicationTests
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match 'foo', :to => 'foo#bar'
|
match 'foo', :to => 'foo#bar'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -161,7 +161,7 @@ module ApplicationTests
|
||||||
assert_equal 'bar', last_response.body
|
assert_equal 'bar', last_response.body
|
||||||
|
|
||||||
app_file 'config/routes.rb', <<-RUBY
|
app_file 'config/routes.rb', <<-RUBY
|
||||||
ActionController::Routing::Routes.draw do |map|
|
AppTemplate.routes.draw do |map|
|
||||||
match 'foo', :to => 'foo#baz'
|
match 'foo', :to => 'foo#baz'
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
|
@ -16,6 +16,7 @@ module InitializerTests
|
||||||
c.root = app_path
|
c.root = app_path
|
||||||
c.i18n.load_path << "my/other/locale.yml"
|
c.i18n.load_path << "my/other/locale.yml"
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
|
|
||||||
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
|
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
|
||||||
|
|
|
@ -14,6 +14,7 @@ class PathsTest < Test::Unit::TestCase
|
||||||
ActionController::Base.session_store = nil
|
ActionController::Base.session_store = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Object.const_set(:AppTemplate, Rails.application)
|
||||||
Rails.initialize!
|
Rails.initialize!
|
||||||
@paths = Rails.application.config.paths
|
@paths = Rails.application.config.paths
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ require 'abstract_unit'
|
||||||
require 'rails/paths'
|
require 'rails/paths'
|
||||||
|
|
||||||
class PathsTest < ActiveSupport::TestCase
|
class PathsTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@root = Rails::Application::Root.new("/foo/bar")
|
@root = Rails::Application::Root.new("/foo/bar")
|
||||||
end
|
end
|
||||||
|
@ -228,4 +227,4 @@ class PathsTest < ActiveSupport::TestCase
|
||||||
@root.app.eager_load!
|
@root.app.eager_load!
|
||||||
assert_equal ["/foo/bar/app"], @root.load_paths
|
assert_equal ["/foo/bar/app"], @root.load_paths
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue