aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/configuration_test.rb30
-rw-r--r--railties/test/application/generators_test.rb13
-rw-r--r--railties/test/application/initializer_test.rb196
-rw-r--r--railties/test/application/initializers/boot_test.rb (renamed from railties/test/initializer/boot_test.rb)2
-rw-r--r--railties/test/application/initializers/check_ruby_version_test.rb (renamed from railties/test/initializer/check_ruby_version_test.rb)2
-rw-r--r--railties/test/application/initializers/frameworks_test.rb80
-rw-r--r--railties/test/application/initializers/i18n_test.rb55
-rw-r--r--railties/test/application/initializers/initializers_test.rb55
-rw-r--r--railties/test/application/initializers/load_path_test.rb62
-rw-r--r--railties/test/application/initializers/notifications_test.rb (renamed from railties/test/application/notifications_test.rb)0
-rw-r--r--railties/test/application/middleware_test.rb7
-rw-r--r--railties/test/application/paths_test.rb (renamed from railties/test/initializer/path_test.rb)4
-rw-r--r--railties/test/application/rackup_test.rb (renamed from railties/test/application/load_test.rb)2
-rw-r--r--railties/test/application/routing_test.rb78
-rw-r--r--railties/test/fixtures/eager/zoo.rb3
-rw-r--r--railties/test/fixtures/eager/zoo/reptile_house.rb2
-rw-r--r--railties/test/fixtures/environment_with_constant.rb1
-rw-r--r--railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb4
-rw-r--r--railties/test/fixtures/plugins/alternate/a/lib/.gitignore0
-rw-r--r--railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore0
-rw-r--r--railties/test/fixtures/plugins/default/empty/.gitignore0
-rw-r--r--railties/test/fixtures/plugins/default/gemlike/init.rb1
-rw-r--r--railties/test/fixtures/plugins/default/gemlike/lib/gemlike.rb2
-rw-r--r--railties/test/fixtures/plugins/default/gemlike/rails/init.rb7
-rw-r--r--railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb0
-rw-r--r--railties/test/fixtures/plugins/default/stubby/about.yml2
-rw-r--r--railties/test/fixtures/plugins/default/stubby/init.rb7
-rw-r--r--railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb2
-rw-r--r--railties/test/fixtures/plugins/engines/engine/app/controllers/engine_controller.rb2
-rw-r--r--railties/test/fixtures/plugins/engines/engine/app/metal/engine_metal.rb10
-rw-r--r--railties/test/fixtures/plugins/engines/engine/app/models/engine_model.rb2
-rw-r--r--railties/test/fixtures/plugins/engines/engine/config/locales/en.yml2
-rw-r--r--railties/test/fixtures/plugins/engines/engine/config/routes.rb3
-rw-r--r--railties/test/fixtures/plugins/engines/engine/init.rb3
-rw-r--r--railties/test/generators/mailer_generator_test.rb39
-rw-r--r--railties/test/generators/named_base_test.rb70
-rw-r--r--railties/test/generators_test.rb1
-rw-r--r--railties/test/isolation/abstract_unit.rb21
-rw-r--r--railties/test/mocks/routes.rb6
-rw-r--r--railties/test/plugins/vendored_test.rb388
-rw-r--r--railties/test/railties/configuration_test.rb (renamed from railties/test/plugins/configuration_test.rb)2
-rw-r--r--railties/test/railties/engine_test.rb23
-rw-r--r--railties/test/railties/framework_extension_test.rb (renamed from railties/test/plugins/framework_extension_test.rb)16
-rw-r--r--railties/test/railties/plugin_ordering_test.rb72
-rw-r--r--railties/test/railties/plugin_test.rb99
-rw-r--r--railties/test/railties/shared_tests.rb306
-rw-r--r--railties/test/vendor/gems/dummy-gem-a-0.4.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-a-0.4.0/lib/dummy-gem-a.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-b-0.4.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-b-0.4.0/lib/dummy-gem-b.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-b-0.6.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-b-0.6.0/lib/dummy-gem-b.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-c-0.4.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-c-0.4.0/lib/dummy-gem-c.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-c-0.6.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-c-0.6.0/lib/dummy-gem-c.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-d-1.0.0/lib/dummy-gem-d.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-e-1.0.0/.specification28
-rw-r--r--railties/test/vendor/gems/dummy-gem-e-1.0.0/lib/dummy-gem-e.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-f-1.0.0/.specification39
-rw-r--r--railties/test/vendor/gems/dummy-gem-f-1.0.0/lib/dummy-gem-f.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-g-1.0.0/.specification39
-rw-r--r--railties/test/vendor/gems/dummy-gem-g-1.0.0/lib/dummy-gem-g.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification29
-rw-r--r--railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification41
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile0
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification41
-rw-r--r--railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification49
-rw-r--r--railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb1
72 files changed, 937 insertions, 1164 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 6968e87986..666c47af67 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -1,7 +1,7 @@
require "isolation/abstract_unit"
module ApplicationTests
- class InitializerTest < Test::Unit::TestCase
+ class ConfigurationTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def new_app
@@ -19,6 +19,13 @@ module ApplicationTests
FileUtils.rm_rf("#{app_path}/config/environments")
end
+ test "Rails::Application.instance is nil until app is initialized" do
+ require 'rails'
+ assert_nil Rails::Application.instance
+ require "#{app_path}/config/environment"
+ assert_equal AppTemplate::Application.instance, Rails::Application.instance
+ end
+
test "the application root is set correctly" do
require "#{app_path}/config/environment"
assert_equal Pathname.new(app_path), Rails.application.root
@@ -52,21 +59,12 @@ module ApplicationTests
end
end
- test "if there's no config.active_support.bare, all of ActiveSupport is required" do
- use_frameworks []
+ test "Rails.root should be a Pathname" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
require "#{app_path}/config/environment"
- assert_nothing_raised { [1,2,3].rand }
- end
-
- test "config.active_support.bare does not require all of ActiveSupport" do
- add_to_config "config.active_support.bare = true"
-
- use_frameworks []
-
- Dir.chdir("#{app_path}/app") do
- require "#{app_path}/config/environment"
- assert_raises(NoMethodError) { [1,2,3].rand }
- end
+ assert_instance_of Pathname, Rails.root
end
test "marking the application as threadsafe sets the correct config variables" do
@@ -129,7 +127,7 @@ module ApplicationTests
value = value.reverse if key =~ /baz/
}]
RUBY
-
+
assert_nothing_raised do
require "#{app_path}/config/application"
end
diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb
index e1e51c318c..1e6e30e9c3 100644
--- a/railties/test/application/generators_test.rb
+++ b/railties/test/application/generators_test.rb
@@ -92,18 +92,5 @@ module ApplicationTests
assert_equal({ :plugin => { :generator => "-g" } }, c.generators.aliases)
end
end
-
- test "generators with hashes are deep merged" do
- with_config do |c|
- c.generators do |g|
- g.orm :datamapper, :migration => false
- g.plugin :aliases => { :generator => "-g" },
- :generator => true
- end
- end
-
- assert Rails::Generators.aliases.size >= 1
- assert Rails::Generators.options.size >= 1
- end
end
end
diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb
deleted file mode 100644
index 053757979b..0000000000
--- a/railties/test/application/initializer_test.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-require "isolation/abstract_unit"
-
-module ApplicationTests
- class InitializerTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- boot_rails
- FileUtils.rm_rf "#{app_path}/config/environments"
- end
-
- test "initializing an application adds the application paths to the load path" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- RUBY
-
- require "#{app_path}/config/environment"
- assert $:.include?("#{app_path}/app/models")
- end
-
- test "eager loading loads parent classes before children" do
- app_file "lib/zoo.rb", <<-ZOO
- class Zoo ; include ReptileHouse ; end
- ZOO
- app_file "lib/zoo/reptile_house.rb", <<-ZOO
- module Zoo::ReptileHouse ; end
- ZOO
-
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.eager_load_paths << "#{app_path}/lib"
- RUBY
-
- require "#{app_path}/config/environment"
-
- assert Zoo
- end
-
- test "load environment with global" do
- app_file "config/environments/development.rb", <<-RUBY
- $initialize_test_set_from_env = 'success'
- AppTemplate::Application.configure do
- config.cache_classes = true
- config.time_zone = "Brasilia"
- end
- RUBY
-
- assert_nil $initialize_test_set_from_env
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.time_zone = "UTC"
- RUBY
-
- require "#{app_path}/config/environment"
- assert_equal "success", $initialize_test_set_from_env
- assert AppTemplate::Application.config.cache_classes
- assert_equal "Brasilia", AppTemplate::Application.config.time_zone
- end
-
- test "action_controller load paths set only if action controller in use" do
- assert_nothing_raised NameError do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- RUBY
-
- use_frameworks []
- require "#{app_path}/config/environment"
- end
- end
-
- test "after_initialize block works correctly" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.after_initialize { $test_after_initialize_block1 = "success" }
- config.after_initialize { $test_after_initialize_block2 = "congratulations" }
- RUBY
- require "#{app_path}/config/environment"
-
- assert_equal "success", $test_after_initialize_block1
- assert_equal "congratulations", $test_after_initialize_block2
- end
-
- test "after_initialize block works correctly when no block is passed" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.after_initialize { $test_after_initialize_block1 = "success" }
- config.after_initialize # don't pass a block, this is what we're testing!
- config.after_initialize { $test_after_initialize_block2 = "congratulations" }
- RUBY
- require "#{app_path}/config/environment"
-
- assert_equal "success", $test_after_initialize_block1
- assert_equal "congratulations", $test_after_initialize_block2
- end
-
- test "after_initialize runs after frameworks have been initialized" do
- $activerecord_configurations = nil
- add_to_config <<-RUBY
- config.after_initialize { $activerecord_configurations = ActiveRecord::Base.configurations }
- RUBY
-
- require "#{app_path}/config/environment"
- assert $activerecord_configurations
- assert $activerecord_configurations['development']
- end
-
- # i18n
- test "setting another default locale" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.i18n.default_locale = :de
- RUBY
- require "#{app_path}/config/environment"
-
- assert_equal :de, I18n.default_locale
- end
-
- test "no config locales dir present should return empty load path" do
- FileUtils.rm_rf "#{app_path}/config/locales"
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- RUBY
- require "#{app_path}/config/environment"
-
- assert_equal [], Rails.application.config.i18n.load_path
- end
-
- test "config locales dir present should be added to load path" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- RUBY
-
- require "#{app_path}/config/environment"
- assert_equal ["#{app_path}/config/locales/en.yml"], Rails.application.config.i18n.load_path
- end
-
- test "config defaults should be added with config settings" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.i18n.load_path << "my/other/locale.yml"
- RUBY
- require "#{app_path}/config/environment"
-
- assert_equal [
- "#{app_path}/config/locales/en.yml", "my/other/locale.yml"
- ], Rails.application.config.i18n.load_path
- end
-
- # DB middleware
- test "database middleware doesn't initialize when session store is not active_record" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- config.action_controller.session_store = :cookie_store
- RUBY
- require "#{app_path}/config/environment"
-
- assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
- end
-
- test "database middleware initializes when session store is active record" do
- add_to_config "config.action_controller.session_store = :active_record_store"
-
- require "#{app_path}/config/environment"
-
- expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
- middleware = Rails.application.config.middleware.map { |m| m.klass }
- assert_equal expects, middleware & expects
- end
-
- test "Rails.root should be a Pathname" do
- add_to_config <<-RUBY
- config.root = "#{app_path}"
- RUBY
- require "#{app_path}/config/environment"
- assert_instance_of Pathname, Rails.root
- end
- end
-
- class InitializerCustomFrameworkExtensionsTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- boot_rails
- FileUtils.rm_rf "#{app_path}/config/environments"
- end
-
- test "database middleware doesn't initialize when activerecord is not in frameworks" do
- use_frameworks []
- require "#{app_path}/config/environment"
-
- assert_nil defined?(ActiveRecord)
- end
- end
-end
diff --git a/railties/test/initializer/boot_test.rb b/railties/test/application/initializers/boot_test.rb
index 5ee3c45b21..5ec562f12f 100644
--- a/railties/test/initializer/boot_test.rb
+++ b/railties/test/application/initializers/boot_test.rb
@@ -1,6 +1,6 @@
require "isolation/abstract_unit"
-module BootTests
+module ApplicationTests
class GemBooting < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/application/initializers/check_ruby_version_test.rb
index 311f19a28a..58782b2511 100644
--- a/railties/test/initializer/check_ruby_version_test.rb
+++ b/railties/test/application/initializers/check_ruby_version_test.rb
@@ -1,6 +1,6 @@
require "isolation/abstract_unit"
-module InitializerTests
+module ApplicationTests
class CheckRubyVersionTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb
new file mode 100644
index 0000000000..ea052320ef
--- /dev/null
+++ b/railties/test/application/initializers/frameworks_test.rb
@@ -0,0 +1,80 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ class FrameworlsTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ boot_rails
+ FileUtils.rm_rf "#{app_path}/config/environments"
+ end
+
+ # AC & AM
+ test "set load paths set only if action controller or action mailer are in use" do
+ assert_nothing_raised NameError do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
+
+ use_frameworks []
+ require "#{app_path}/config/environment"
+ end
+ end
+
+ test "sets action_controller and action_mailer load paths" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
+
+ require "#{app_path}/config/environment"
+ ActionController::Base.view_paths.include?(File.expand_path("app/views", app_path))
+ ActionMailer::Base.view_paths.include?(File.expand_path("app/views", app_path))
+ end
+
+ # AS
+ test "if there's no config.active_support.bare, all of ActiveSupport is required" do
+ use_frameworks []
+ require "#{app_path}/config/environment"
+ assert_nothing_raised { [1,2,3].rand }
+ end
+
+ test "config.active_support.bare does not require all of ActiveSupport" do
+ add_to_config "config.active_support.bare = true"
+
+ use_frameworks []
+
+ Dir.chdir("#{app_path}/app") do
+ require "#{app_path}/config/environment"
+ assert_raises(NoMethodError) { [1,2,3].rand }
+ end
+ end
+
+ # AR
+ test "database middleware doesn't initialize when session store is not active_record" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.action_controller.session_store = :cookie_store
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
+ end
+
+ test "database middleware initializes when session store is active record" do
+ add_to_config "config.action_controller.session_store = :active_record_store"
+
+ require "#{app_path}/config/environment"
+
+ expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
+ middleware = Rails.application.config.middleware.map { |m| m.klass }
+ assert_equal expects, middleware & expects
+ end
+
+ test "database middleware doesn't initialize when activerecord is not in frameworks" do
+ use_frameworks []
+ require "#{app_path}/config/environment"
+ assert_nil defined?(ActiveRecord)
+ end
+ end
+end
diff --git a/railties/test/application/initializers/i18n_test.rb b/railties/test/application/initializers/i18n_test.rb
new file mode 100644
index 0000000000..99b2d86013
--- /dev/null
+++ b/railties/test/application/initializers/i18n_test.rb
@@ -0,0 +1,55 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ class I18nTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ boot_rails
+ FileUtils.rm_rf "#{app_path}/config/environments"
+ end
+
+ # i18n
+ test "setting another default locale" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.i18n.default_locale = :de
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal :de, I18n.default_locale
+ end
+
+ test "no config locales dir present should return empty load path" do
+ FileUtils.rm_rf "#{app_path}/config/locales"
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal [], Rails.application.config.i18n.load_path
+ end
+
+ test "config locales dir present should be added to load path" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
+
+ require "#{app_path}/config/environment"
+ assert_equal ["#{app_path}/config/locales/en.yml"], Rails.application.config.i18n.load_path
+ end
+
+ test "config defaults should be added with config settings" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.i18n.load_path << "my/other/locale.yml"
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal [
+ "#{app_path}/config/locales/en.yml", "my/other/locale.yml"
+ ], Rails.application.config.i18n.load_path
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/test/application/initializers/initializers_test.rb b/railties/test/application/initializers/initializers_test.rb
new file mode 100644
index 0000000000..0c3de7ce33
--- /dev/null
+++ b/railties/test/application/initializers/initializers_test.rb
@@ -0,0 +1,55 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ class InitializersTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ boot_rails
+ FileUtils.rm_rf "#{app_path}/config/environments"
+ end
+
+ test "load initializers" do
+ app_file "config/initializers/foo.rb", "$foo = true"
+ require "#{app_path}/config/environment"
+ assert $foo
+ end
+
+ test "after_initialize block works correctly" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.after_initialize { $test_after_initialize_block1 = "success" }
+ config.after_initialize { $test_after_initialize_block2 = "congratulations" }
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal "success", $test_after_initialize_block1
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
+
+ test "after_initialize block works correctly when no block is passed" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.after_initialize { $test_after_initialize_block1 = "success" }
+ config.after_initialize # don't pass a block, this is what we're testing!
+ config.after_initialize { $test_after_initialize_block2 = "congratulations" }
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal "success", $test_after_initialize_block1
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
+
+ test "after_initialize runs after frameworks have been initialized" do
+ $activerecord_configurations = nil
+ add_to_config <<-RUBY
+ config.after_initialize { $activerecord_configurations = ActiveRecord::Base.configurations }
+ RUBY
+
+ require "#{app_path}/config/environment"
+ assert $activerecord_configurations
+ assert $activerecord_configurations['development']
+ end
+ end
+end
diff --git a/railties/test/application/initializers/load_path_test.rb b/railties/test/application/initializers/load_path_test.rb
new file mode 100644
index 0000000000..714b6114a2
--- /dev/null
+++ b/railties/test/application/initializers/load_path_test.rb
@@ -0,0 +1,62 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ class LoadPathTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ boot_rails
+ FileUtils.rm_rf "#{app_path}/config/environments"
+ end
+
+ # General
+ test "initializing an application adds the application paths to the load path" do
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ RUBY
+
+ require "#{app_path}/config/environment"
+ assert $:.include?("#{app_path}/app/models")
+ end
+
+ test "eager loading loads parent classes before children" do
+ app_file "lib/zoo.rb", <<-ZOO
+ class Zoo ; include ReptileHouse ; end
+ ZOO
+ app_file "lib/zoo/reptile_house.rb", <<-ZOO
+ module Zoo::ReptileHouse ; end
+ ZOO
+
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.eager_load_paths << "#{app_path}/lib"
+ RUBY
+
+ require "#{app_path}/config/environment"
+
+ assert Zoo
+ end
+
+ test "load environment with global" do
+ app_file "config/environments/development.rb", <<-RUBY
+ $initialize_test_set_from_env = 'success'
+ AppTemplate::Application.configure do
+ config.cache_classes = true
+ config.time_zone = "Brasilia"
+ end
+ RUBY
+
+ assert_nil $initialize_test_set_from_env
+ add_to_config <<-RUBY
+ config.root = "#{app_path}"
+ config.time_zone = "UTC"
+ RUBY
+
+ require "#{app_path}/config/environment"
+ assert_equal "success", $initialize_test_set_from_env
+ assert AppTemplate::Application.config.cache_classes
+ assert_equal "Brasilia", AppTemplate::Application.config.time_zone
+ end
+ end
+end
diff --git a/railties/test/application/notifications_test.rb b/railties/test/application/initializers/notifications_test.rb
index 061bb34c19..061bb34c19 100644
--- a/railties/test/application/notifications_test.rb
+++ b/railties/test/application/initializers/notifications_test.rb
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 31696598ce..0b92cdba54 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -23,7 +23,6 @@ module ApplicationTests
"ActionDispatch::Cookies",
"ActionDispatch::Session::CookieStore",
"ActionDispatch::Flash",
- "ActionDispatch::Cascade",
"ActionDispatch::ParamsParser",
"Rack::MethodOverride",
"ActionDispatch::Head",
@@ -70,6 +69,12 @@ module ApplicationTests
assert_equal "Rack::Config", middleware.first
end
+ test "shows cascade if any metal exists" do
+ app_file "app/metal/foo.rb", "class Foo; end"
+ boot!
+ assert middleware.include?("ActionDispatch::Cascade")
+ end
+
private
def boot!
require "#{app_path}/config/environment"
diff --git a/railties/test/initializer/path_test.rb b/railties/test/application/paths_test.rb
index 2048dc57bb..ac0aa27c64 100644
--- a/railties/test/initializer/path_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -1,7 +1,7 @@
require "isolation/abstract_unit"
-module InitializerTests
- class PathTest < Test::Unit::TestCase
+module ApplicationTests
+ class PathsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
diff --git a/railties/test/application/load_test.rb b/railties/test/application/rackup_test.rb
index 1c5811b07a..f909c1b282 100644
--- a/railties/test/application/load_test.rb
+++ b/railties/test/application/rackup_test.rb
@@ -1,7 +1,7 @@
require "isolation/abstract_unit"
module ApplicationTests
- class LoadTest < Test::Unit::TestCase
+ class RackupTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def rackup
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
diff --git a/railties/test/fixtures/eager/zoo.rb b/railties/test/fixtures/eager/zoo.rb
deleted file mode 100644
index 8b10ef984b..0000000000
--- a/railties/test/fixtures/eager/zoo.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Zoo
- include ReptileHouse
-end \ No newline at end of file
diff --git a/railties/test/fixtures/eager/zoo/reptile_house.rb b/railties/test/fixtures/eager/zoo/reptile_house.rb
deleted file mode 100644
index 82bbafce79..0000000000
--- a/railties/test/fixtures/eager/zoo/reptile_house.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Zoo::ReptileHouse
-end \ No newline at end of file
diff --git a/railties/test/fixtures/environment_with_constant.rb b/railties/test/fixtures/environment_with_constant.rb
deleted file mode 100644
index 23e1f7afd9..0000000000
--- a/railties/test/fixtures/environment_with_constant.rb
+++ /dev/null
@@ -1 +0,0 @@
-$initialize_test_set_from_env = 'success'
diff --git a/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb b/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
deleted file mode 100644
index b33f2dad18..0000000000
--- a/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-class AGenerator < Rails::Generator::Base
- def manifest
- end
-end
diff --git a/railties/test/fixtures/plugins/alternate/a/lib/.gitignore b/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
+++ /dev/null
diff --git a/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore b/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
+++ /dev/null
diff --git a/railties/test/fixtures/plugins/default/empty/.gitignore b/railties/test/fixtures/plugins/default/empty/.gitignore
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/test/fixtures/plugins/default/empty/.gitignore
+++ /dev/null
diff --git a/railties/test/fixtures/plugins/default/gemlike/init.rb b/railties/test/fixtures/plugins/default/gemlike/init.rb
deleted file mode 100644
index 6a771b5b68..0000000000
--- a/railties/test/fixtures/plugins/default/gemlike/init.rb
+++ /dev/null
@@ -1 +0,0 @@
-raise 'This init.rb should not be evaluated because rails/init.rb exists'
diff --git a/railties/test/fixtures/plugins/default/gemlike/lib/gemlike.rb b/railties/test/fixtures/plugins/default/gemlike/lib/gemlike.rb
deleted file mode 100644
index 2088103e45..0000000000
--- a/railties/test/fixtures/plugins/default/gemlike/lib/gemlike.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Gemlike
-end \ No newline at end of file
diff --git a/railties/test/fixtures/plugins/default/gemlike/rails/init.rb b/railties/test/fixtures/plugins/default/gemlike/rails/init.rb
deleted file mode 100644
index 171a293eb3..0000000000
--- a/railties/test/fixtures/plugins/default/gemlike/rails/init.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# I have access to my directory and the Rails config.
-raise 'directory expected but undefined in init.rb' unless defined? directory
-raise 'config expected but undefined in init.rb' unless defined? config
-
-# My lib/ dir must be in the load path.
-require 'gemlike'
-raise 'missing mixin from my lib/ dir' unless defined? Gemlike
diff --git a/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb b/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb
+++ /dev/null
diff --git a/railties/test/fixtures/plugins/default/stubby/about.yml b/railties/test/fixtures/plugins/default/stubby/about.yml
deleted file mode 100644
index d85a7cc0e3..0000000000
--- a/railties/test/fixtures/plugins/default/stubby/about.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-author: Plugin Author
-version: 1.0.0 \ No newline at end of file
diff --git a/railties/test/fixtures/plugins/default/stubby/init.rb b/railties/test/fixtures/plugins/default/stubby/init.rb
deleted file mode 100644
index 81beeb0d32..0000000000
--- a/railties/test/fixtures/plugins/default/stubby/init.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# I have access to my directory and the Rails config.
-raise 'directory expected but undefined in init.rb' unless defined? directory
-raise 'config expected but undefined in init.rb' unless defined? config
-
-# My lib/ dir must be in the load path.
-require 'stubby_mixin'
-raise 'missing mixin from my lib/ dir' unless defined? StubbyMixin
diff --git a/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb b/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb
deleted file mode 100644
index 2d569e5002..0000000000
--- a/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module StubbyMixin
-end
diff --git a/railties/test/fixtures/plugins/engines/engine/app/controllers/engine_controller.rb b/railties/test/fixtures/plugins/engines/engine/app/controllers/engine_controller.rb
deleted file mode 100644
index 323ee1c4dc..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/app/controllers/engine_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class EngineController
-end \ No newline at end of file
diff --git a/railties/test/fixtures/plugins/engines/engine/app/metal/engine_metal.rb b/railties/test/fixtures/plugins/engines/engine/app/metal/engine_metal.rb
deleted file mode 100644
index d67a127ca7..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/app/metal/engine_metal.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class EngineMetal
- def self.call(env)
- if env["PATH_INFO"] =~ /^\/metal/
- [200, {"Content-Type" => "text/html"}, ["Engine metal"]]
- else
- [404, {"Content-Type" => "text/html"}, ["Not Found"]]
- end
- end
-end
-
diff --git a/railties/test/fixtures/plugins/engines/engine/app/models/engine_model.rb b/railties/test/fixtures/plugins/engines/engine/app/models/engine_model.rb
deleted file mode 100644
index e265712185..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/app/models/engine_model.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class EngineModel
-end \ No newline at end of file
diff --git a/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml b/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
deleted file mode 100644
index 641a7e035c..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-en:
- hello: "Hello from Engine"
diff --git a/railties/test/fixtures/plugins/engines/engine/config/routes.rb b/railties/test/fixtures/plugins/engines/engine/config/routes.rb
deleted file mode 100644
index da44595693..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/config/routes.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-ActionController::Routing::Routes.draw do |map|
- match '/engine', :to => "engine"
-end
diff --git a/railties/test/fixtures/plugins/engines/engine/init.rb b/railties/test/fixtures/plugins/engines/engine/init.rb
deleted file mode 100644
index 64e9ae6c30..0000000000
--- a/railties/test/fixtures/plugins/engines/engine/init.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# My app/models dir must be in the load path.
-require 'engine_model'
-raise LoadError, 'missing model from my app/models dir' unless defined?(EngineModel)
diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb
index dfc3130f77..0b7f5c6817 100644
--- a/railties/test/generators/mailer_generator_test.rb
+++ b/railties/test/generators/mailer_generator_test.rb
@@ -7,7 +7,18 @@ class MailerGeneratorTest < Rails::Generators::TestCase
def test_mailer_skeleton_is_created
run_generator
- assert_file "app/mailers/notifier.rb", /class Notifier < ActionMailer::Base/
+ assert_file "app/mailers/notifier.rb" do |mailer|
+ assert_match /class Notifier < ActionMailer::Base/, mailer
+ assert_match /self\.defaults :from => "from@example.com"/, mailer
+ end
+ end
+
+ def test_mailer_with_i18n_helper
+ run_generator
+ assert_file "app/mailers/notifier.rb" do |mailer|
+ assert_match /en\.actionmailer\.notifier\.foo\.subject/, mailer
+ assert_match /en\.actionmailer\.notifier\.bar\.subject/, mailer
+ end
end
def test_check_class_collision
@@ -24,8 +35,15 @@ class MailerGeneratorTest < Rails::Generators::TestCase
def test_invokes_default_template_engine
run_generator
- assert_file "app/views/notifier/foo.erb", /app\/views\/notifier\/foo/
- assert_file "app/views/notifier/bar.erb", /app\/views\/notifier\/bar/
+ assert_file "app/views/notifier/foo.text.erb" do |view|
+ assert_match /app\/views\/notifier\/foo/, view
+ assert_match /<%= @greeting %>/, view
+ end
+
+ assert_file "app/views/notifier/bar.text.erb" do |view|
+ assert_match /app\/views\/notifier\/bar/, view
+ assert_match /<%= @greeting %>/, view
+ end
end
def test_invokes_default_template_engine_even_with_no_action
@@ -40,7 +58,18 @@ class MailerGeneratorTest < Rails::Generators::TestCase
def test_actions_are_turned_into_methods
run_generator
- assert_file "app/mailers/notifier.rb", /def foo/
- assert_file "app/mailers/notifier.rb", /def bar/
+
+ assert_file "app/mailers/notifier.rb" do |mailer|
+ assert_instance_method :foo, mailer do |foo|
+ assert_match /mail\(:to => "to@example.org"\)/, foo
+ assert_match /@greeting = "Hi"/, foo
+ end
+
+ assert_instance_method :bar, mailer do |bar|
+ assert_match /mail\(:to => "to@example.org"\)/, bar
+ assert_match /@greeting = "Hi"/, bar
+ end
+ end
+
end
end
diff --git a/railties/test/generators/named_base_test.rb b/railties/test/generators/named_base_test.rb
index 99eb431a49..f327fb1282 100644
--- a/railties/test/generators/named_base_test.rb
+++ b/railties/test/generators/named_base_test.rb
@@ -16,28 +16,68 @@ class NamedBaseTest < Rails::Generators::TestCase
tests Rails::Generators::ScaffoldControllerGenerator
def test_named_generator_attributes
- g = generator ["admin/foo"]
- assert_equal 'admin/foo', g.name
- assert_equal %w(admin), g.class_path
- assert_equal 1, g.class_nesting_depth
- assert_equal 'Admin::Foo', g.class_name
- assert_equal 'foo', g.singular_name
- assert_equal 'foos', g.plural_name
- assert_equal g.singular_name, g.file_name
- assert_equal "admin_#{g.plural_name}", g.table_name
+ g = generator ['admin/foo']
+ assert_name g, 'admin/foo', :name
+ assert_name g, %w(admin), :class_path
+ assert_name g, 'Admin::Foo', :class_name
+ assert_name g, 'admin/foo', :file_path
+ assert_name g, 'foo', :file_name
+ assert_name g, 'foo', :singular_name
+ assert_name g, 'foos', :plural_name
+ assert_name g, 'admin.foo', :i18n_scope
+ assert_name g, 'admin_foos', :table_name
+ end
+
+ def test_named_generator_attributes_as_ruby
+ g = generator ['Admin::Foo']
+ assert_name g, 'Admin::Foo', :name
+ assert_name g, %w(admin), :class_path
+ assert_name g, 'Admin::Foo', :class_name
+ assert_name g, 'admin/foo', :file_path
+ assert_name g, 'foo', :file_name
+ assert_name g, 'foo', :singular_name
+ assert_name g, 'foos', :plural_name
+ assert_name g, 'admin.foo', :i18n_scope
+ assert_name g, 'admin_foos', :table_name
end
def test_named_generator_attributes_without_pluralized
ActiveRecord::Base.pluralize_table_names = false
- g = generator ["admin/foo"]
- assert_equal "admin_#{g.singular_name}", g.table_name
+ g = generator ['admin/foo']
+ assert_name g, 'admin_foo', :table_name
end
def test_scaffold_plural_names
- g = generator ["ProductLine"]
- assert_equal "ProductLines", g.controller_name
- assert_equal "ProductLines", g.controller_class_name
- assert_equal "product_lines", g.controller_file_name
+ g = generator ['admin/foo']
+ assert_name g, 'admin/foos', :controller_name
+ assert_name g, %w(admin), :controller_class_path
+ assert_name g, 'Admin::Foos', :controller_class_name
+ assert_name g, 'admin/foos', :controller_file_path
+ assert_name g, 'foos', :controller_file_name
+ assert_name g, 'admin.foos', :controller_i18n_scope
+ end
+
+ def test_scaffold_plural_names_as_ruby
+ g = generator ['Admin::Foo']
+ assert_name g, 'Admin::Foos', :controller_name
+ assert_name g, %w(admin), :controller_class_path
+ assert_name g, 'Admin::Foos', :controller_class_name
+ assert_name g, 'admin/foos', :controller_file_path
+ assert_name g, 'foos', :controller_file_name
+ assert_name g, 'admin.foos', :controller_i18n_scope
end
+ def test_application_name
+ g = generator ['Admin::Foo']
+ Rails.stubs(:application).returns(Object.new)
+ assert_name g, "object", :application_name
+ Rails.stubs(:application).returns(nil)
+ assert_name g, "application", :application_name
+ end
+
+ protected
+
+ def assert_name(generator, value, method)
+ assert_equal value, generator.send(method)
+ end
end
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb
index f37b684f73..33cc27bd84 100644
--- a/railties/test/generators_test.rb
+++ b/railties/test/generators_test.rb
@@ -99,6 +99,7 @@ class GeneratorsTest < Rails::Generators::TestCase
assert_match /Rails:/, output
assert_match /^ model$/, output
assert_match /^ scaffold_controller$/, output
+ assert_no_match /^ app$/, output
end
def test_rails_generators_with_others_information
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index dc5fddb19d..940585836c 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -100,6 +100,8 @@ module TestHelpers
end
class Bukkit
+ attr_reader :path
+
def initialize(path)
@path = path
end
@@ -118,10 +120,29 @@ module TestHelpers
def plugin(name, string = "")
dir = "#{app_path}/vendor/plugins/#{name}"
FileUtils.mkdir_p(dir)
+
File.open("#{dir}/init.rb", 'w') do |f|
f.puts "::#{name.upcase} = 'loaded'"
f.puts string
end
+
+ Bukkit.new(dir).tap do |bukkit|
+ yield bukkit if block_given?
+ end
+ end
+
+ def engine(name)
+ dir = "#{app_path}/random/#{name}"
+ FileUtils.mkdir_p(dir)
+
+ app = File.readlines("#{app_path}/config/application.rb")
+ app.insert(2, "$:.unshift(\"#{dir}/lib\")")
+ app.insert(3, "require #{name.inspect}")
+
+ File.open("#{app_path}/config/application.rb", 'r+') do |f|
+ f.puts app
+ end
+
Bukkit.new(dir).tap do |bukkit|
yield bukkit if block_given?
end
diff --git a/railties/test/mocks/routes.rb b/railties/test/mocks/routes.rb
deleted file mode 100644
index ea12863683..0000000000
--- a/railties/test/mocks/routes.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module ActionController
- module Routing
- class Routes
- end
- end
-end
diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb
deleted file mode 100644
index 41073d33a2..0000000000
--- a/railties/test/plugins/vendored_test.rb
+++ /dev/null
@@ -1,388 +0,0 @@
-require "isolation/abstract_unit"
-
-module PluginsTest
- class VendoredTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
-
- @plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin|
- plugin.write "lib/bukkits.rb", "class Bukkits; end"
- end
- end
-
- def boot_rails
- super
- require "#{app_path}/config/environment"
- end
-
- def app
- @app ||= Rails.application
- end
-
- test "it loads the plugin's init.rb file" do
- boot_rails
- assert_equal "loaded", BUKKITS
- end
-
- test "the init.rb file has access to the config object" do
- boot_rails
- assert_equal :debug, LEVEL
- end
-
- test "the plugin puts its lib directory on the load path" do
- boot_rails
- require "bukkits"
- assert_equal "Bukkits", Bukkits.name
- end
-
- test "plugin init is ran before application initializers" do
- plugin "foo", "$foo = true" do |plugin|
- plugin.write "lib/foo.rb", "module Foo; end"
- end
-
- app_file 'config/initializers/foo.rb', <<-RUBY
- raise "no $foo" unless $foo
- raise "no Foo" unless Foo
- RUBY
-
- boot_rails
- end
-
- test "plugin paths get added to the AS::Dependency list" do
- boot_rails
- assert_equal "Bukkits", Bukkits.name
- end
-
- test "plugin constants do not get reloaded by default" do
- boot_rails
- assert_equal "Bukkits", Bukkits.name
- ActiveSupport::Dependencies.clear
- @plugin.delete("lib/bukkits.rb")
- assert_nothing_raised { Bukkits }
- end
-
- test "plugin constants get reloaded if config.reload_plugins is set" do
- add_to_config <<-RUBY
- config.reload_plugins = true
- RUBY
-
- boot_rails
-
- assert_equal "Bukkits", Bukkits.name
- ActiveSupport::Dependencies.clear
- @plugin.delete("lib/bukkits.rb")
- assert_raises(NameError) { Bukkits }
- end
-
- test "plugin should work without init.rb" do
- @plugin.delete("init.rb")
-
- boot_rails
-
- require "bukkits"
- assert_nothing_raised { Bukkits }
- end
-
- test "the plugin puts its models directory on the load path" do
- @plugin.write "app/models/my_bukkit.rb", "class MyBukkit ; end"
-
- boot_rails
-
- assert_nothing_raised { MyBukkit }
- end
-
- test "the plugin puts is controllers directory on the load path" do
- @plugin.write "app/controllers/bukkit_controller.rb", "class BukkitController ; end"
-
- boot_rails
-
- assert_nothing_raised { BukkitController }
- end
-
- test "the plugin adds its view to the load path" do
- @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY
- class BukkitController < ActionController::Base
- def index
- end
- end
- RUBY
-
- @plugin.write "app/views/bukkit/index.html.erb", "Hello bukkits"
-
- boot_rails
-
- require "action_controller"
- require "rack/mock"
- response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/"))
- assert_equal "Hello bukkits\n", response[2].body
- end
-
- test "the plugin adds helpers to the controller's views" do
- @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY
- class BukkitController < ActionController::Base
- def index
- end
- end
- RUBY
-
- @plugin.write "app/helpers/bukkit_helper.rb", <<-RUBY
- module BukkitHelper
- def bukkits
- "bukkits"
- end
- end
- RUBY
-
- @plugin.write "app/views/bukkit/index.html.erb", "Hello <%= bukkits %>"
-
- boot_rails
-
- require "rack/mock"
- response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/"))
- assert_equal "Hello bukkits\n", response[2].body
- end
-
- test "routes.rb are added to the router" do
- @plugin.write "config/routes.rb", <<-RUBY
- class Sprokkit
- def self.call(env)
- [200, {'Content-Type' => 'text/html'}, ["I am a Sprokkit"]]
- end
- end
-
- ActionController::Routing::Routes.draw do
- match "/sprokkit", :to => Sprokkit
- end
- RUBY
-
- boot_rails
- require "rack/mock"
- response = Rails.application.call(Rack::MockRequest.env_for("/sprokkit"))
- assert_equal "I am a Sprokkit", response[2].join
- end
-
- test "tasks are loaded by default" do
- $executed = false
- @plugin.write "lib/tasks/foo.rake", <<-RUBY
- task :foo do
- $executed = true
- end
- RUBY
-
- boot_rails
- require 'rake'
- require 'rake/rdoctask'
- require 'rake/testtask'
- Rails.application.load_tasks
- Rake::Task[:foo].invoke
- assert $executed
- end
-
- test "deprecated tasks are also loaded" do
- $executed = false
- @plugin.write "tasks/foo.rake", <<-RUBY
- task :foo do
- $executed = true
- end
- RUBY
-
- boot_rails
- require 'rake'
- require 'rake/rdoctask'
- require 'rake/testtask'
- Rails.application.load_tasks
- Rake::Task[:foo].invoke
- assert $executed
- end
-
- test "i18n files are added with lower priority than application ones" do
- add_to_config <<-RUBY
- config.i18n.load_path << "#{app_path}/app/locales/en.yml"
- RUBY
-
- app_file 'app/locales/en.yml', <<-YAML
-en:
- bar: "1"
-YAML
-
- app_file 'config/locales/en.yml', <<-YAML
-en:
- foo: "2"
- bar: "2"
-YAML
-
- @plugin.write 'config/locales/en.yml', <<-YAML
-en:
- foo: "3"
-YAML
-
- boot_rails
-
- assert_equal %W(
- #{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml
- #{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml
- #{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml
- #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml
- #{app_path}/vendor/plugins/bukkits/config/locales/en.yml
- #{app_path}/config/locales/en.yml
- #{app_path}/app/locales/en.yml
- ).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) }
-
- assert_equal "2", I18n.t(:foo)
- assert_equal "1", I18n.t(:bar)
- end
-
- test "plugin metals are added to the middleware stack" do
- @plugin.write 'app/metal/foo_metal.rb', <<-RUBY
- class FooMetal
- def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["FooMetal"]]
- end
- end
- RUBY
-
- boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
-
- get "/"
- assert_equal 200, last_response.status
- assert_equal "FooMetal", last_response.body
- end
-
- test "use plugin middleware in application config" do
- plugin "foo" do |plugin|
- plugin.write "lib/foo.rb", <<-RUBY
- class Foo
- def initialize(app)
- @app = app
- end
-
- def call(env)
- @app.call(env)
- end
- end
- RUBY
- end
-
- add_to_config "config.middleware.use :Foo"
-
- boot_rails
- end
-
- test "namespaced controllers with namespaced routes" do
- @plugin.write "config/routes.rb", <<-RUBY
- ActionController::Routing::Routes.draw do
- namespace :admin do
- match "index", :to => "admin/foo#index"
- end
- end
- RUBY
-
- @plugin.write "app/controllers/admin/foo_controller.rb", <<-RUBY
- class Admin::FooController < ApplicationController
- def index
- render :text => "Rendered from namespace"
- end
- end
- RUBY
-
- boot_rails
-
- require 'rack/test'
- extend Rack::Test::Methods
-
- get "/admin/index"
- assert_equal 200, last_response.status
- assert_equal "Rendered from namespace", last_response.body
- end
-
- test "plugin with initializers" do
- $plugin_initializer = false
- @plugin.write "config/initializers/foo.rb", <<-RUBY
- $plugin_initializer = true
- RUBY
-
- boot_rails
- assert $plugin_initializer
- end
-
- test "plugin cannot declare an engine for it" do
- @plugin.write "lib/bukkits.rb", <<-RUBY
- class Bukkits
- class Engine < Rails::Engine
- end
- end
- RUBY
-
- @plugin.write "init.rb", <<-RUBY
- require "bukkits"
- RUBY
-
- rescued = false
-
- begin
- boot_rails
- rescue Exception => e
- rescued = true
- assert_equal '"bukkits" is a Railtie/Engine and cannot be installed as plugin', e.message
- end
-
- assert rescued, "Expected boot rails to fail"
- end
- end
-
- class VendoredOrderingTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- $arr = []
- plugin "a_plugin", "$arr << :a"
- plugin "b_plugin", "$arr << :b"
- plugin "c_plugin", "$arr << :c"
- end
-
- def boot_rails
- super
- require "#{app_path}/config/environment"
- end
-
- test "plugins are loaded alphabetically by default" do
- boot_rails
- assert_equal [:a, :b, :c], $arr
- end
-
- test "if specified, only those plugins are loaded" do
- add_to_config "config.plugins = [:b_plugin]"
- boot_rails
- assert_equal [:b], $arr
- end
-
- test "the plugins are initialized in the order they are specified" do
- add_to_config "config.plugins = [:b_plugin, :a_plugin]"
- boot_rails
- assert_equal [:b, :a], $arr
- end
-
- test "if :all is specified, the remaining plugins are loaded in alphabetical order" do
- add_to_config "config.plugins = [:c_plugin, :all]"
- boot_rails
- assert_equal [:c, :a, :b], $arr
- end
-
- test "if :all is at the beginning, it represents the plugins not otherwise specified" do
- add_to_config "config.plugins = [:all, :b_plugin]"
- boot_rails
- assert_equal [:a, :c, :b], $arr
- end
-
- test "plugin order array is strings" do
- add_to_config "config.plugins = %w( c_plugin all )"
- boot_rails
- assert_equal [:c, :a, :b], $arr
- end
- end
-end
diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/railties/configuration_test.rb
index c59040c712..c5ff6dad9c 100644
--- a/railties/test/plugins/configuration_test.rb
+++ b/railties/test/railties/configuration_test.rb
@@ -1,6 +1,6 @@
require "isolation/abstract_unit"
-module PluginsTest
+module RailtiesTest
class ConfigurationTest < Test::Unit::TestCase
def setup
build_app
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
new file mode 100644
index 0000000000..374f5ea93c
--- /dev/null
+++ b/railties/test/railties/engine_test.rb
@@ -0,0 +1,23 @@
+require "isolation/abstract_unit"
+require "railties/shared_tests"
+
+module RailtiesTest
+ class EngineTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+ include SharedTests
+
+ def setup
+ build_app
+
+ @plugin = engine "bukkits" do |plugin|
+ plugin.write "lib/bukkits.rb", <<-RUBY
+ class Bukkits
+ class Engine < ::Rails::Engine
+ end
+ end
+ RUBY
+ plugin.write "lib/another.rb", "class Another; end"
+ end
+ end
+ end
+end
diff --git a/railties/test/plugins/framework_extension_test.rb b/railties/test/railties/framework_extension_test.rb
index d57fd4e635..48e513cf01 100644
--- a/railties/test/plugins/framework_extension_test.rb
+++ b/railties/test/railties/framework_extension_test.rb
@@ -1,6 +1,6 @@
require "isolation/abstract_unit"
-module PluginsTest
+module RailtiesTest
class FrameworkExtensionTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
@@ -46,6 +46,20 @@ module PluginsTest
AppTemplate::Application.load_generators
assert $ran_block
end
+
+ test "railtie initializer" do
+ $ran_block = false
+
+ class MyTie < Rails::Railtie
+ initializer :something_nice do
+ $ran_block = true
+ end
+ end
+
+ assert !$ran_block
+ require "#{app_path}/config/environment"
+ assert $ran_block
+ end
end
class ActiveRecordExtensionTest < Test::Unit::TestCase
diff --git a/railties/test/railties/plugin_ordering_test.rb b/railties/test/railties/plugin_ordering_test.rb
new file mode 100644
index 0000000000..f6ca493fdf
--- /dev/null
+++ b/railties/test/railties/plugin_ordering_test.rb
@@ -0,0 +1,72 @@
+require "isolation/abstract_unit"
+
+module RailtiesTest
+ class PluginOrderingTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ $arr = []
+ plugin "a_plugin", "$arr << :a"
+ plugin "b_plugin", "$arr << :b"
+ plugin "c_plugin", "$arr << :c"
+ end
+
+ def boot_rails
+ super
+ require "#{app_path}/config/environment"
+ end
+
+ test "plugins are loaded alphabetically by default" do
+ boot_rails
+ assert_equal [:a, :b, :c], $arr
+ end
+
+ test "if specified, only those plugins are loaded" do
+ add_to_config "config.plugins = [:b_plugin]"
+ boot_rails
+ assert_equal [:b], $arr
+ end
+
+ test "the plugins are initialized in the order they are specified" do
+ add_to_config "config.plugins = [:b_plugin, :a_plugin]"
+ boot_rails
+ assert_equal [:b, :a], $arr
+ end
+
+ test "if :all is specified, the remaining plugins are loaded in alphabetical order" do
+ add_to_config "config.plugins = [:c_plugin, :all]"
+ boot_rails
+ assert_equal [:c, :a, :b], $arr
+ end
+
+ test "if :all is at the beginning, it represents the plugins not otherwise specified" do
+ add_to_config "config.plugins = [:all, :b_plugin]"
+ boot_rails
+ assert_equal [:a, :c, :b], $arr
+ end
+
+ test "plugin order array is strings" do
+ add_to_config "config.plugins = %w( c_plugin all )"
+ boot_rails
+ assert_equal [:c, :a, :b], $arr
+ end
+
+ test "can require lib file from a different plugin" do
+ plugin "foo", "require 'bar'" do |plugin|
+ plugin.write "lib/foo.rb", "$foo = true"
+ end
+
+ plugin "bar", "require 'foo'" do |plugin|
+ plugin.write "lib/bar.rb", "$bar = true"
+ end
+
+ add_to_config "config.plugins = [:foo, :bar]"
+
+ boot_rails
+
+ assert $foo
+ assert $bar
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb
new file mode 100644
index 0000000000..0adc31e3ed
--- /dev/null
+++ b/railties/test/railties/plugin_test.rb
@@ -0,0 +1,99 @@
+require "isolation/abstract_unit"
+require "railties/shared_tests"
+
+module RailtiesTest
+ class PluginTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+ include SharedTests
+
+ def setup
+ build_app
+
+ @plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin|
+ plugin.write "lib/bukkits.rb", "class Bukkits; end"
+ plugin.write "lib/another.rb", "class Another; end"
+ end
+ end
+
+ test "plugin can load the file with the same name in lib" do
+ boot_rails
+ require "bukkits"
+ assert_equal "Bukkits", Bukkits.name
+ end
+
+ test "it loads the plugin's init.rb file" do
+ boot_rails
+ assert_equal "loaded", BUKKITS
+ end
+
+ test "the init.rb file has access to the config object" do
+ boot_rails
+ assert_equal :debug, LEVEL
+ end
+
+ test "plugin_init_is_ran_before_application_ones" do
+ plugin "foo", "$foo = true" do |plugin|
+ plugin.write "lib/foo.rb", "module Foo; end"
+ end
+
+ app_file 'config/initializers/foo.rb', <<-RUBY
+ raise "no $foo" unless $foo
+ raise "no Foo" unless Foo
+ RUBY
+
+ boot_rails
+ assert $foo
+ end
+
+ test "plugin should work without init.rb" do
+ @plugin.delete("init.rb")
+
+ boot_rails
+
+ require "bukkits"
+ assert_nothing_raised { Bukkits }
+ end
+
+ test "plugin cannot declare an engine for it" do
+ @plugin.write "lib/bukkits.rb", <<-RUBY
+ class Bukkits
+ class Engine < Rails::Engine
+ end
+ end
+ RUBY
+
+ @plugin.write "init.rb", <<-RUBY
+ require "bukkits"
+ RUBY
+
+ rescued = false
+
+ begin
+ boot_rails
+ rescue Exception => e
+ rescued = true
+ assert_equal '"bukkits" is a Railtie/Engine and cannot be installed as plugin', e.message
+ end
+
+ assert rescued, "Expected boot rails to fail"
+ end
+
+ test "deprecated tasks are also loaded" do
+ $executed = false
+ @plugin.write "tasks/foo.rake", <<-RUBY
+ task :foo do
+ $executed = true
+ end
+ RUBY
+
+ boot_rails
+ require 'rake'
+ require 'rake/rdoctask'
+ require 'rake/testtask'
+ Rails.application.load_tasks
+ Rake::Task[:foo].invoke
+ assert $executed
+ end
+
+ end
+end
diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb
new file mode 100644
index 0000000000..fc4a19e7e7
--- /dev/null
+++ b/railties/test/railties/shared_tests.rb
@@ -0,0 +1,306 @@
+module RailtiesTest
+ # Holds tests shared between plugin and engines
+ module SharedTests
+ def boot_rails
+ super
+ require "#{app_path}/config/environment"
+ end
+
+ def app
+ @app ||= Rails.application
+ end
+
+ def test_plugin_puts_its_lib_directory_on_load_path
+ boot_rails
+ require "another"
+ assert_equal "Another", Another.name
+ end
+
+ def test_plugin_paths_get_added_to_as_dependency_list
+ boot_rails
+ assert_equal "Another", Another.name
+ end
+
+ def test_plugins_constants_are_not_reloaded_by_default
+ boot_rails
+ assert_equal "Another", Another.name
+ ActiveSupport::Dependencies.clear
+ @plugin.delete("lib/another.rb")
+ assert_nothing_raised { Another }
+ end
+
+ def test_plugin_constants_get_reloaded_if_config_reload_plugins
+ add_to_config <<-RUBY
+ config.reload_plugins = true
+ RUBY
+
+ boot_rails
+
+ assert_equal "Another", Another.name
+ ActiveSupport::Dependencies.clear
+ @plugin.delete("lib/another.rb")
+ assert_raises(NameError) { Another }
+ end
+
+ def test_plugin_puts_its_models_directory_on_load_path
+ @plugin.write "app/models/my_bukkit.rb", "class MyBukkit ; end"
+ boot_rails
+ assert_nothing_raised { MyBukkit }
+ end
+
+ def test_plugin_puts_its_controllers_directory_on_the_load_path
+ @plugin.write "app/controllers/bukkit_controller.rb", "class BukkitController ; end"
+ boot_rails
+ assert_nothing_raised { BukkitController }
+ end
+
+ def test_plugin_adds_its_views_to_view_paths
+ @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY
+ class BukkitController < ActionController::Base
+ def index
+ end
+ end
+ RUBY
+
+ @plugin.write "app/views/bukkit/index.html.erb", "Hello bukkits"
+
+ boot_rails
+
+ require "action_controller"
+ require "rack/mock"
+ response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/"))
+ assert_equal "Hello bukkits\n", response[2].body
+ end
+
+ def test_plugin_adds_its_views_to_view_paths_with_lower_proriority
+ @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY
+ class BukkitController < ActionController::Base
+ def index
+ end
+ end
+ RUBY
+
+ @plugin.write "app/views/bukkit/index.html.erb", "Hello bukkits"
+ app_file "app/views/bukkit/index.html.erb", "Hi bukkits"
+
+ boot_rails
+
+ require "action_controller"
+ require "rack/mock"
+ response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/"))
+ assert_equal "Hi bukkits\n", response[2].body
+ end
+
+ def test_plugin_adds_helpers_to_controller_views
+ @plugin.write "app/controllers/bukkit_controller.rb", <<-RUBY
+ class BukkitController < ActionController::Base
+ def index
+ end
+ end
+ RUBY
+
+ @plugin.write "app/helpers/bukkit_helper.rb", <<-RUBY
+ module BukkitHelper
+ def bukkits
+ "bukkits"
+ end
+ end
+ RUBY
+
+ @plugin.write "app/views/bukkit/index.html.erb", "Hello <%= bukkits %>"
+
+ boot_rails
+
+ require "rack/mock"
+ response = BukkitController.action(:index).call(Rack::MockRequest.env_for("/"))
+ assert_equal "Hello bukkits\n", response[2].body
+ end
+
+ def test_routes_are_added_to_router
+ @plugin.write "config/routes.rb", <<-RUBY
+ class Sprokkit
+ def self.call(env)
+ [200, {'Content-Type' => 'text/html'}, ["I am a Sprokkit"]]
+ end
+ end
+
+ ActionController::Routing::Routes.draw do
+ match "/sprokkit", :to => Sprokkit
+ end
+ RUBY
+
+ boot_rails
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get "/sprokkit"
+ assert_equal "I am a Sprokkit", last_response.body
+ end
+
+ def test_routes_in_plugins_have_lower_priority_than_application_ones
+ 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.write "app/controllers/bar_controller.rb", <<-RUBY
+ class BarController < ActionController::Base
+ def index
+ render :text => "bar"
+ end
+ end
+ RUBY
+
+ @plugin.write "config/routes.rb", <<-RUBY
+ ActionController::Routing::Routes.draw do |map|
+ match 'foo', :to => 'bar#index'
+ match 'bar', :to => 'bar#index'
+ end
+ RUBY
+
+ boot_rails
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get '/foo'
+ assert_equal 'foo', last_response.body
+
+ get '/bar'
+ assert_equal 'bar', last_response.body
+ end
+
+ def test_rake_tasks_lib_tasks_are_loaded
+ $executed = false
+ @plugin.write "lib/tasks/foo.rake", <<-RUBY
+ task :foo do
+ $executed = true
+ end
+ RUBY
+
+ boot_rails
+ require 'rake'
+ require 'rake/rdoctask'
+ require 'rake/testtask'
+ Rails.application.load_tasks
+ Rake::Task[:foo].invoke
+ assert $executed
+ end
+
+ def test_i18n_files_have_lower_priority_than_application_ones
+ add_to_config <<-RUBY
+ config.i18n.load_path << "#{app_path}/app/locales/en.yml"
+ RUBY
+
+ app_file 'app/locales/en.yml', <<-YAML
+en:
+ bar: "1"
+YAML
+
+ app_file 'config/locales/en.yml', <<-YAML
+en:
+ foo: "2"
+ bar: "2"
+YAML
+
+ @plugin.write 'config/locales/en.yml', <<-YAML
+en:
+ foo: "3"
+YAML
+
+ boot_rails
+
+ assert_equal %W(
+ #{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml
+ #{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml
+ #{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml
+ #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml
+ #{@plugin.path}/config/locales/en.yml
+ #{app_path}/config/locales/en.yml
+ #{app_path}/app/locales/en.yml
+ ).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) }
+
+ assert_equal "2", I18n.t(:foo)
+ assert_equal "1", I18n.t(:bar)
+ end
+
+ def test_plugin_metals_added_to_middleware_stack
+ @plugin.write 'app/metal/foo_metal.rb', <<-RUBY
+ class FooMetal
+ def self.call(env)
+ [200, { "Content-Type" => "text/html"}, ["FooMetal"]]
+ end
+ end
+ RUBY
+
+ boot_rails
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get "/"
+ assert_equal 200, last_response.status
+ assert_equal "FooMetal", last_response.body
+ end
+
+ def test_namespaced_controllers_with_namespaced_routes
+ @plugin.write "config/routes.rb", <<-RUBY
+ ActionController::Routing::Routes.draw do
+ namespace :admin do
+ match "index", :to => "admin/foo#index"
+ end
+ end
+ RUBY
+
+ @plugin.write "app/controllers/admin/foo_controller.rb", <<-RUBY
+ class Admin::FooController < ApplicationController
+ def index
+ render :text => "Rendered from namespace"
+ end
+ end
+ RUBY
+
+ boot_rails
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get "/admin/index"
+ assert_equal 200, last_response.status
+ assert_equal "Rendered from namespace", last_response.body
+ end
+
+ def test_plugin_initializers
+ $plugin_initializer = false
+ @plugin.write "config/initializers/foo.rb", <<-RUBY
+ $plugin_initializer = true
+ RUBY
+
+ boot_rails
+ assert $plugin_initializer
+ end
+
+ def test_plugin_midleware_referenced_in_configuration
+ @plugin.write "lib/bukkits.rb", <<-RUBY
+ class Bukkits
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ @app.call(env)
+ end
+ end
+ RUBY
+
+ add_to_config "config.middleware.use \"Bukkits\""
+ boot_rails
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/test/vendor/gems/dummy-gem-a-0.4.0/.specification b/railties/test/vendor/gems/dummy-gem-a-0.4.0/.specification
deleted file mode 100644
index 86dba2092c..0000000000
--- a/railties/test/vendor/gems/dummy-gem-a-0.4.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-a
-version: !ruby/object:Gem::Version
- version: 0.4.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-a.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem A
diff --git a/railties/test/vendor/gems/dummy-gem-a-0.4.0/lib/dummy-gem-a.rb b/railties/test/vendor/gems/dummy-gem-a-0.4.0/lib/dummy-gem-a.rb
deleted file mode 100644
index 0453b38ab8..0000000000
--- a/railties/test/vendor/gems/dummy-gem-a-0.4.0/lib/dummy-gem-a.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_A_VERSION="0.4.0"
diff --git a/railties/test/vendor/gems/dummy-gem-b-0.4.0/.specification b/railties/test/vendor/gems/dummy-gem-b-0.4.0/.specification
deleted file mode 100644
index 5ea692d7a1..0000000000
--- a/railties/test/vendor/gems/dummy-gem-b-0.4.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-b
-version: !ruby/object:Gem::Version
- version: 0.4.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-b.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem B
diff --git a/railties/test/vendor/gems/dummy-gem-b-0.4.0/lib/dummy-gem-b.rb b/railties/test/vendor/gems/dummy-gem-b-0.4.0/lib/dummy-gem-b.rb
deleted file mode 100644
index 850b5dda83..0000000000
--- a/railties/test/vendor/gems/dummy-gem-b-0.4.0/lib/dummy-gem-b.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_B_VERSION="0.4.0"
diff --git a/railties/test/vendor/gems/dummy-gem-b-0.6.0/.specification b/railties/test/vendor/gems/dummy-gem-b-0.6.0/.specification
deleted file mode 100644
index ab4707124a..0000000000
--- a/railties/test/vendor/gems/dummy-gem-b-0.6.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-b
-version: !ruby/object:Gem::Version
- version: 0.6.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-b.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem B
diff --git a/railties/test/vendor/gems/dummy-gem-b-0.6.0/lib/dummy-gem-b.rb b/railties/test/vendor/gems/dummy-gem-b-0.6.0/lib/dummy-gem-b.rb
deleted file mode 100644
index 7d6d01cd48..0000000000
--- a/railties/test/vendor/gems/dummy-gem-b-0.6.0/lib/dummy-gem-b.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_B_VERSION="0.6.0"
diff --git a/railties/test/vendor/gems/dummy-gem-c-0.4.0/.specification b/railties/test/vendor/gems/dummy-gem-c-0.4.0/.specification
deleted file mode 100644
index f90f60424c..0000000000
--- a/railties/test/vendor/gems/dummy-gem-c-0.4.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-c
-version: !ruby/object:Gem::Version
- version: 0.4.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-c.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem C
diff --git a/railties/test/vendor/gems/dummy-gem-c-0.4.0/lib/dummy-gem-c.rb b/railties/test/vendor/gems/dummy-gem-c-0.4.0/lib/dummy-gem-c.rb
deleted file mode 100644
index 1a416bef82..0000000000
--- a/railties/test/vendor/gems/dummy-gem-c-0.4.0/lib/dummy-gem-c.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_C_VERSION="0.4.0"
diff --git a/railties/test/vendor/gems/dummy-gem-c-0.6.0/.specification b/railties/test/vendor/gems/dummy-gem-c-0.6.0/.specification
deleted file mode 100644
index e75c0aa66a..0000000000
--- a/railties/test/vendor/gems/dummy-gem-c-0.6.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-c
-version: !ruby/object:Gem::Version
- version: 0.6.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-c.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem C
diff --git a/railties/test/vendor/gems/dummy-gem-c-0.6.0/lib/dummy-gem-c.rb b/railties/test/vendor/gems/dummy-gem-c-0.6.0/lib/dummy-gem-c.rb
deleted file mode 100644
index 9ba2ca8bb5..0000000000
--- a/railties/test/vendor/gems/dummy-gem-c-0.6.0/lib/dummy-gem-c.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_C_VERSION="0.6.0"
diff --git a/railties/test/vendor/gems/dummy-gem-d-1.0.0/lib/dummy-gem-d.rb b/railties/test/vendor/gems/dummy-gem-d-1.0.0/lib/dummy-gem-d.rb
deleted file mode 100644
index e5cb007e5f..0000000000
--- a/railties/test/vendor/gems/dummy-gem-d-1.0.0/lib/dummy-gem-d.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_D_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-e-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-e-1.0.0/.specification
deleted file mode 100644
index ce4443c8be..0000000000
--- a/railties/test/vendor/gems/dummy-gem-e-1.0.0/.specification
+++ /dev/null
@@ -1,28 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-e
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-files:
-- lib
-- lib/dummy-gem-e.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem E
diff --git a/railties/test/vendor/gems/dummy-gem-e-1.0.0/lib/dummy-gem-e.rb b/railties/test/vendor/gems/dummy-gem-e-1.0.0/lib/dummy-gem-e.rb
deleted file mode 100644
index 48bf91a701..0000000000
--- a/railties/test/vendor/gems/dummy-gem-e-1.0.0/lib/dummy-gem-e.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_E_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-f-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-f-1.0.0/.specification
deleted file mode 100644
index 70a36b9a8c..0000000000
--- a/railties/test/vendor/gems/dummy-gem-f-1.0.0/.specification
+++ /dev/null
@@ -1,39 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-f
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-- !ruby/object:Gem::Dependency
- name: absolutely-no-such-gem
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-files:
-- lib
-- lib/dummy-gem-f.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem F
diff --git a/railties/test/vendor/gems/dummy-gem-f-1.0.0/lib/dummy-gem-f.rb b/railties/test/vendor/gems/dummy-gem-f-1.0.0/lib/dummy-gem-f.rb
deleted file mode 100644
index 0271c8c48a..0000000000
--- a/railties/test/vendor/gems/dummy-gem-f-1.0.0/lib/dummy-gem-f.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_F_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-g-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-g-1.0.0/.specification
deleted file mode 100644
index 27e29912a6..0000000000
--- a/railties/test/vendor/gems/dummy-gem-g-1.0.0/.specification
+++ /dev/null
@@ -1,39 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-g
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-- !ruby/object:Gem::Dependency
- name: dummy-gem-f
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-files:
-- lib
-- lib/dummy-gem-g.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem G
diff --git a/railties/test/vendor/gems/dummy-gem-g-1.0.0/lib/dummy-gem-g.rb b/railties/test/vendor/gems/dummy-gem-g-1.0.0/lib/dummy-gem-g.rb
deleted file mode 100644
index 8fc056586c..0000000000
--- a/railties/test/vendor/gems/dummy-gem-g-1.0.0/lib/dummy-gem-g.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_G_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification
deleted file mode 100644
index b3f7930948..0000000000
--- a/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification
+++ /dev/null
@@ -1,29 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-h
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-files:
-- lib
-- lib/dummy-gem-h.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem H
diff --git a/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb b/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb
deleted file mode 100644
index 0f91234936..0000000000
--- a/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_H_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification
deleted file mode 100644
index 50b4969da5..0000000000
--- a/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification
+++ /dev/null
@@ -1,41 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-i
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-- !ruby/object:Gem::Dependency
- name: dummy-gem-i
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-extensions:
-- ext/dummy-gem-i/extconf.rb
-files:
-- lib
-- lib/dummy-gem-i.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem G
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile b/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile
+++ /dev/null
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb b/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb
deleted file mode 100644
index 2f9a376c2c..0000000000
--- a/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_I_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification
deleted file mode 100644
index 2c456546fc..0000000000
--- a/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification
+++ /dev/null
@@ -1,41 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-j
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-- !ruby/object:Gem::Dependency
- name: dummy-gem-j
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-extensions:
-- ext/dummy-gem-j/extconf.rb
-files:
-- lib
-- lib/dummy-gem-j.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem G
diff --git a/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb b/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb
deleted file mode 100644
index 8ecd363ff8..0000000000
--- a/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_J_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification
deleted file mode 100644
index 20edd0f856..0000000000
--- a/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification
+++ /dev/null
@@ -1,49 +0,0 @@
---- !ruby/object:Gem::Specification
-name: dummy-gem-k
-version: !ruby/object:Gem::Version
- version: 1.3.0
-platform: ruby
-authors:
-- "Nobody"
-date: 2008-10-03 00:00:00 -04:00
-dependencies:
-- !ruby/object:Gem::Dependency
- name: dummy-gem-k
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-- !ruby/object:Gem::Dependency
- name: dummy-gem-h
- type: :development
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.0
- version:
-files:
-- lib
-- lib/dummy-gem-k.rb
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-specification_version: 2
-summary: Dummy Gem I
diff --git a/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb b/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb
deleted file mode 100644
index 97fb1d69ce..0000000000
--- a/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb
+++ /dev/null
@@ -1 +0,0 @@
-DUMMY_GEM_K_VERSION="1.0.0"