aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-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/initializer_test.rb102
-rw-r--r--railties/test/plugin_loader_test.rb12
-rw-r--r--railties/test/plugin_locator_test.rb4
-rw-r--r--railties/test/plugin_test.rb16
-rw-r--r--railties/test/rails_info_controller_test.rb4
8 files changed, 85 insertions, 63 deletions
diff --git a/railties/test/fixtures/plugins/default/gemlike/init.rb b/railties/test/fixtures/plugins/default/gemlike/init.rb
new file mode 100644
index 0000000000..6a771b5b68
--- /dev/null
+++ b/railties/test/fixtures/plugins/default/gemlike/init.rb
@@ -0,0 +1 @@
+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
new file mode 100644
index 0000000000..2088103e45
--- /dev/null
+++ b/railties/test/fixtures/plugins/default/gemlike/lib/gemlike.rb
@@ -0,0 +1,2 @@
+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
new file mode 100644
index 0000000000..171a293eb3
--- /dev/null
+++ b/railties/test/fixtures/plugins/default/gemlike/rails/init.rb
@@ -0,0 +1,7 @@
+# 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/initializer_test.rb b/railties/test/initializer_test.rb
index efce4f292d..dee7abe05f 100644
--- a/railties/test/initializer_test.rb
+++ b/railties/test/initializer_test.rb
@@ -30,66 +30,66 @@ class Initializer_load_environment_Test < Test::Unit::TestCase
end
-class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase
- def setup
- config = ConfigurationMock.new("")
- config.after_initialize do
- $test_after_initialize_block1 = "success"
- end
- config.after_initialize do
- $test_after_initialize_block2 = "congratulations"
- end
- assert_nil $test_after_initialize_block1
- assert_nil $test_after_initialize_block2
+uses_mocha 'Initializer after_initialize' do
+ class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase
+ def setup
+ config = ConfigurationMock.new("")
+ config.after_initialize do
+ $test_after_initialize_block1 = "success"
+ end
+ config.after_initialize do
+ $test_after_initialize_block2 = "congratulations"
+ end
+ assert_nil $test_after_initialize_block1
+ assert_nil $test_after_initialize_block2
- Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true)
- Rails::Initializer.run(:after_initialize, config)
- end
+ Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true)
+ Rails::Initializer.run(:after_initialize, config)
+ end
- def teardown
- $test_after_initialize_block1 = nil
- $test_after_initialize_block2 = nil
- end
+ def teardown
+ $test_after_initialize_block1 = nil
+ $test_after_initialize_block2 = nil
+ end
- def test_should_have_called_the_first_after_initialize_block
- assert_equal "success", $test_after_initialize_block1
- end
+ def test_should_have_called_the_first_after_initialize_block
+ assert_equal "success", $test_after_initialize_block1
+ end
- def test_should_have_called_the_second_after_initialize_block
- assert_equal "congratulations", $test_after_initialize_block2
+ def test_should_have_called_the_second_after_initialize_block
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
end
-end
-class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase
+ class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase
+ def setup
+ config = ConfigurationMock.new("")
+ config.after_initialize do
+ $test_after_initialize_block1 = "success"
+ end
+ config.after_initialize # don't pass a block, this is what we're testing!
+ config.after_initialize do
+ $test_after_initialize_block2 = "congratulations"
+ end
+ assert_nil $test_after_initialize_block1
- def setup
- config = ConfigurationMock.new("")
- config.after_initialize do
- $test_after_initialize_block1 = "success"
+ Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true)
+ Rails::Initializer.run(:after_initialize, config)
end
- config.after_initialize # don't pass a block, this is what we're testing!
- config.after_initialize do
- $test_after_initialize_block2 = "congratulations"
- end
- assert_nil $test_after_initialize_block1
-
- Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true)
- Rails::Initializer.run(:after_initialize, config)
- end
- def teardown
- $test_after_initialize_block1 = nil
- $test_after_initialize_block2 = nil
- end
+ def teardown
+ $test_after_initialize_block1 = nil
+ $test_after_initialize_block2 = nil
+ end
- def test_should_have_called_the_first_after_initialize_block
- assert_equal "success", $test_after_initialize_block1, "should still get set"
- end
+ def test_should_have_called_the_first_after_initialize_block
+ assert_equal "success", $test_after_initialize_block1, "should still get set"
+ end
- def test_should_have_called_the_second_after_initialize_block
- assert_equal "congratulations", $test_after_initialize_block2
+ def test_should_have_called_the_second_after_initialize_block
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
end
-
end
uses_mocha 'framework paths' do
@@ -173,7 +173,7 @@ uses_mocha "Initializer plugin loading tests" do
def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
load_plugins!
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
end
def test_all_plugins_loaded_when_all_is_used
@@ -181,7 +181,7 @@ uses_mocha "Initializer plugin loading tests" do
only_load_the_following_plugins! plugin_names
load_plugins!
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :gemlike, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
end
def test_all_plugins_loaded_after_all
@@ -189,7 +189,7 @@ uses_mocha "Initializer plugin loading tests" do
only_load_the_following_plugins! plugin_names
load_plugins!
failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
+ assert_plugins [:stubby, :a, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
end
def test_plugin_names_may_be_strings
diff --git a/railties/test/plugin_loader_test.rb b/railties/test/plugin_loader_test.rb
index bce4446f79..e5fc0926eb 100644
--- a/railties/test/plugin_loader_test.rb
+++ b/railties/test/plugin_loader_test.rb
@@ -48,16 +48,16 @@ uses_mocha "Plugin Loader Tests" do
end
def test_should_find_all_availble_plugins_and_return_as_all_plugins
- assert_plugins [:stubby, :plugin_with_no_lib_dir, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
+ assert_plugins [:stubby, :plugin_with_no_lib_dir, :gemlike, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
end
def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
@configuration.plugins = nil
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
@@ -74,17 +74,17 @@ uses_mocha "Plugin Loader Tests" do
def test_should_load_all_plugins_in_natural_order_when_all_is_used
only_load_the_following_plugins! [:all]
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
- assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :gemlike, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
end
def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
only_load_the_following_plugins! [:stubby, :all, :acts_as_chunky_bacon]
- assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
+ assert_plugins [:stubby, :a, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
end
def test_should_accept_plugin_names_given_as_strings
diff --git a/railties/test/plugin_locator_test.rb b/railties/test/plugin_locator_test.rb
index 5f1dd991ea..363fa27f15 100644
--- a/railties/test/plugin_locator_test.rb
+++ b/railties/test/plugin_locator_test.rb
@@ -47,12 +47,12 @@ uses_mocha "Plugin Locator Tests" do
end
def test_should_return_all_plugins_found_under_the_set_plugin_paths
- assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
+ assert_equal ["a", "acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
end
def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
@configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
- assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
+ assert_equal ["acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
@configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
assert_equal ["a"], @locator.plugins.map(&:name)
diff --git a/railties/test/plugin_test.rb b/railties/test/plugin_test.rb
index 1445338f14..50124240a5 100644
--- a/railties/test/plugin_test.rb
+++ b/railties/test/plugin_test.rb
@@ -5,9 +5,10 @@ uses_mocha "Plugin Tests" do
class PluginTest < Test::Unit::TestCase
def setup
- @initializer = Rails::Initializer.new(Rails::Configuration.new)
- @valid_plugin_path = plugin_fixture_path('default/stubby')
- @empty_plugin_path = plugin_fixture_path('default/empty')
+ @initializer = Rails::Initializer.new(Rails::Configuration.new)
+ @valid_plugin_path = plugin_fixture_path('default/stubby')
+ @empty_plugin_path = plugin_fixture_path('default/empty')
+ @gemlike_plugin_path = plugin_fixture_path('default/gemlike')
end
def test_should_determine_plugin_name_from_the_directory_of_the_plugin
@@ -70,7 +71,14 @@ uses_mocha "Plugin Tests" do
plugin.stubs(:evaluate_init_rb)
plugin.send(:load, @initializer)
end
-
+
+ # This path is fine so nothing is raised
+ assert_nothing_raised do
+ plugin = plugin_for(@gemlike_plugin_path)
+ plugin.stubs(:evaluate_init_rb)
+ plugin.send(:load, @initializer)
+ end
+
# This is an empty path so it raises
assert_raises(LoadError) do
plugin = plugin_for(@empty_plugin_path)
diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb
index 17c7d9deea..e1872ebf33 100644
--- a/railties/test/rails_info_controller_test.rb
+++ b/railties/test/rails_info_controller_test.rb
@@ -30,6 +30,8 @@ class Rails::InfoControllerTest < Test::Unit::TestCase
@controller = Rails::InfoController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+
+ ActionController::Base.consider_all_requests_local = true
end
def test_rails_info_properties_table_rendered_for_local_request
@@ -41,6 +43,8 @@ class Rails::InfoControllerTest < Test::Unit::TestCase
def test_rails_info_properties_error_rendered_for_non_local_request
Rails::InfoController.local_request = false
+ ActionController::Base.consider_all_requests_local = false
+
get :properties
assert_tag :tag => 'p'
assert_response 500